content/canvas/test/test_drawImageIncomplete.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=517056
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 517056</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=517056">Mozilla Bug 517056</a>
michael@0 13 <p id="display">
michael@0 14 <canvas id="c" width="1" height="1"></canvas>
michael@0 15 </p>
michael@0 16 <div id="content" style="display: none">
michael@0 17
michael@0 18 </div>
michael@0 19 <pre id="test">
michael@0 20 <script type="application/javascript">
michael@0 21
michael@0 22 /** Test for Bug 517056 **/
michael@0 23 var ctx = $("c").getContext('2d');
michael@0 24 ctx.fillStyle = "black";
michael@0 25 ctx.fillRect(0, 0, 1, 1);
michael@0 26 var data = ctx.getImageData(0, 0, 1, 1).data;
michael@0 27 is(data[0], 0, "Red channel of black should be 0");
michael@0 28 is(data[1], 0, "Green channel of black should be 0");
michael@0 29 is(data[2], 0, "Blue channel of black should be 0")
michael@0 30 is(data[3], 255, "Alpha channel of black should be opaque");
michael@0 31 var img = new Image();
michael@0 32 // Force a new URI every time, so that we don't run into stupid caching issues.
michael@0 33 img.src = "image_green-1x1.png?" + (new Date + 0) + Math.random();
michael@0 34 // This shouldn't throw
michael@0 35 ctx.drawImage(img, 0, 0);
michael@0 36 var data = ctx.getImageData(0, 0, 1, 1).data;
michael@0 37 is(data[0], 0, "Red channel of black should be 0 and image should have been ignored");
michael@0 38 is(data[1], 0, "Green channel of black should be 0 and image should have been ignored");
michael@0 39 is(data[2], 0, "Blue channel of black should be 0 and image should have been ignored")
michael@0 40 is(data[3], 255, "Alpha channel of black should be opaque and image should have been ignored");
michael@0 41
michael@0 42 SimpleTest.waitForExplicitFinish();
michael@0 43 img.onload = function() {
michael@0 44 ctx.drawImage(img, 0, 0);
michael@0 45 var data = ctx.getImageData(0, 0, 1, 1).data;
michael@0 46 is(data[0], 0, "Red channel of green should be 0");
michael@0 47 is(data[1], 255, "Green channel of green should be 255");
michael@0 48 is(data[2], 0, "Blue channel of green should be 0")
michael@0 49 is(data[3], 255, "Alpha channel of green should be opaque");
michael@0 50
michael@0 51 SimpleTest.finish();
michael@0 52 }
michael@0 53
michael@0 54
michael@0 55
michael@0 56 </script>
michael@0 57 </pre>
michael@0 58 </body>
michael@0 59 </html>

mercurial