1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/test_2d.clearRect.image.offscreen.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<head> 1.7 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.8 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.9 +</head> 1.10 +<body onload="doTest()"> 1.11 +<p id="display"> 1.12 + <canvas id="c" width="1" height="1"></canvas> 1.13 + <img id="img" src="image_green-1x1.png"> 1.14 +</p> 1.15 +<div id="content" style="display: none"> 1.16 + 1.17 +</div> 1.18 +<pre id="test"> 1.19 +<script type="application/javascript"> 1.20 + 1.21 +var c = document.getElementById("c"); 1.22 +var ctx = c.getContext("2d"); 1.23 +var img = document.getElementById("img"); 1.24 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 +function doTest() { 1.28 + ctx.fillStyle = "red"; 1.29 + ctx.fillRect(0, 0, 1, 1); 1.30 + ctx.drawImage(img, -1, 0); 1.31 + ctx.clearRect(0, 0, 1, 1); 1.32 + 1.33 + var data = ctx.getImageData(0, 0, 1, 1).data; 1.34 + is(data[0], 0, "Red channel should be 0"); 1.35 + is(data[1], 0, "Green channel should be 0"); 1.36 + is(data[2], 0, "Blue channel should be 0") 1.37 + is(data[3], 0, "Alpha channel should be 0"); 1.38 + 1.39 + SimpleTest.finish(); 1.40 +} 1.41 + 1.42 +</script> 1.43 +</pre> 1.44 +</body> 1.45 +</html>