1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/test_drawImageIncomplete.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=517056 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 517056</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=517056">Mozilla Bug 517056</a> 1.16 +<p id="display"> 1.17 + <canvas id="c" width="1" height="1"></canvas> 1.18 +</p> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script type="application/javascript"> 1.24 + 1.25 +/** Test for Bug 517056 **/ 1.26 +var ctx = $("c").getContext('2d'); 1.27 +ctx.fillStyle = "black"; 1.28 +ctx.fillRect(0, 0, 1, 1); 1.29 +var data = ctx.getImageData(0, 0, 1, 1).data; 1.30 +is(data[0], 0, "Red channel of black should be 0"); 1.31 +is(data[1], 0, "Green channel of black should be 0"); 1.32 +is(data[2], 0, "Blue channel of black should be 0") 1.33 +is(data[3], 255, "Alpha channel of black should be opaque"); 1.34 +var img = new Image(); 1.35 +// Force a new URI every time, so that we don't run into stupid caching issues. 1.36 +img.src = "image_green-1x1.png?" + (new Date + 0) + Math.random(); 1.37 +// This shouldn't throw 1.38 +ctx.drawImage(img, 0, 0); 1.39 +var data = ctx.getImageData(0, 0, 1, 1).data; 1.40 +is(data[0], 0, "Red channel of black should be 0 and image should have been ignored"); 1.41 +is(data[1], 0, "Green channel of black should be 0 and image should have been ignored"); 1.42 +is(data[2], 0, "Blue channel of black should be 0 and image should have been ignored") 1.43 +is(data[3], 255, "Alpha channel of black should be opaque and image should have been ignored"); 1.44 + 1.45 +SimpleTest.waitForExplicitFinish(); 1.46 +img.onload = function() { 1.47 + ctx.drawImage(img, 0, 0); 1.48 + var data = ctx.getImageData(0, 0, 1, 1).data; 1.49 + is(data[0], 0, "Red channel of green should be 0"); 1.50 + is(data[1], 255, "Green channel of green should be 255"); 1.51 + is(data[2], 0, "Blue channel of green should be 0") 1.52 + is(data[3], 255, "Alpha channel of green should be opaque"); 1.53 + 1.54 + SimpleTest.finish(); 1.55 +} 1.56 + 1.57 + 1.58 + 1.59 +</script> 1.60 +</pre> 1.61 +</body> 1.62 +</html>