blob: 39d7ae4688a8d1781c97a57f058405b85ca26345 [file] [log] [blame]
<!DOCTYPE html>
<title>Canvas test: 2d.imageData.create1.initial</title>
<meta name="author" content="Philip Taylor">
<script src="../common/canvas-tests.js"></script>
<link rel="stylesheet" href="../common/canvas-tests.css">
<body class="show_output">
<h1><a href="index.2d.html">2d</a>.<a href="index.2d.imageData.html">imageData</a>.<a href="index.2d.imageData.create1.html">create1</a>.initial</h1>
<p class="desc">createImageData(imgdata) returns transparent black data of the right size</p>
<div class="refs">Spec references:
<ul>
<li><a href="../annotated-spec/canvas.html#testrefs.2d.imageData.create1.size">2d.imageData.create1.size</a>
<li><a href="../annotated-spec/canvas.html#testrefs.2d.imageData.create.initial">2d.imageData.create.initial</a>
<li><a href="../annotated-spec/canvas.html#testrefs.2d.imageData.initial">2d.imageData.initial</a>
</ul>
</div>
<p class="output">Actual output:</p>
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<ul id="d"></ul>
<script>
_addTest(function(canvas, ctx) {
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var imgdata1 = ctx.getImageData(0, 0, 10, 20);
var imgdata2 = ctx.createImageData(imgdata1);
_assertEqual(imgdata2.data.length, imgdata1.data.length, "imgdata2.data.length", "imgdata1.data.length");
_assertEqual(imgdata2.width, imgdata1.width, "imgdata2.width", "imgdata1.width");
_assertEqual(imgdata2.height, imgdata1.height, "imgdata2.height", "imgdata1.height");
var isTransparentBlack = true;
for (var i = 0; i < imgdata2.data.length; ++i)
if (imgdata2.data[i] !== 0)
isTransparentBlack = false;
_assert(isTransparentBlack, "isTransparentBlack");
});
</script>