OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 </head> | 4 </head> |
5 <body onload="start();"> | 5 <body onload="start();"> |
| 6 <canvas id="webgl" width="200" height="200"></canvas> |
6 <script> | 7 <script> |
| 8 /* |
| 9 * window.createImageBitmap(HTMLCanvasElement) copies the front buffer of WebGL. |
| 10 * crbug.com/438986 |
| 11 */ |
7 window.jsTestIsAsync = true; | 12 window.jsTestIsAsync = true; |
8 | 13 |
9 var canvas = document.createElement("canvas"); | 14 var canvas = document.createElement("canvas"); |
10 canvas.width = 200; | 15 canvas.width = 200; |
11 canvas.height = 200; | 16 canvas.height = 200; |
12 var ctx = canvas.getContext("2d"); | 17 var ctx = canvas.getContext("2d"); |
13 function shouldBeGreen(x, y) { | 18 function shouldBeGreen(x, y) { |
14 d = ctx.getImageData(x, y, 1, 1).data; | 19 d = ctx.getImageData(x, y, 1, 1).data; |
15 shouldBeTrue("d[0] == 0"); | 20 shouldBeTrue("d[0] == 0"); |
16 shouldBeTrue("d[1] == 255"); | 21 shouldBeTrue("d[1] == 255"); |
17 shouldBeTrue("d[2] == 0"); | 22 shouldBeTrue("d[2] == 0"); |
18 shouldBeTrue("d[3] == 255"); | 23 shouldBeTrue("d[3] == 255"); |
19 } | 24 } |
20 | 25 |
21 function start() { | 26 function start() { |
22 var aCanvas = document.createElement("canvas"); | 27 debug("Check the imageBitmap of webgl.") |
23 aCanvas.width = 200; | 28 var webgl_canvas = document.getElementById("webgl"); |
24 aCanvas.height = 200; | 29 var gl = webgl_canvas.getContext("webgl", {preserveDrawingBuffer: false}
); |
25 var gl = aCanvas.getContext("webgl"); | |
26 gl.clearColor(0.0, 1.0, 0.0, 1.0); | 30 gl.clearColor(0.0, 1.0, 0.0, 1.0); |
27 gl.clear(gl.COLOR_BUFFER_BIT); | 31 gl.clear(gl.COLOR_BUFFER_BIT); |
| 32 createImageBitmapAndCheck(webgl_canvas).then(function() { |
| 33 if (window.testRunner) { |
| 34 testRunner.displayAsyncThen(asyncTest); |
| 35 } else { |
| 36 window.requestAnimationFrame(asyncTest); |
| 37 } |
| 38 }); |
| 39 } |
28 | 40 |
29 createImageBitmap(aCanvas).then(function (imageBitmap) { | 41 function createImageBitmapAndCheck(webgl_canvas) { |
| 42 return createImageBitmap(webgl_canvas).then(function (imageBitmap) { |
| 43 ctx.clearRect(0, 0, 200, 200); |
30 ctx.drawImage(imageBitmap, 0, 0); | 44 ctx.drawImage(imageBitmap, 0, 0); |
31 shouldBeGreen(50, 50); | 45 shouldBeGreen(50, 50); |
32 shouldBeGreen(150, 150); | 46 shouldBeGreen(150, 150); |
33 finishJSTest(); | |
34 }, function() { | 47 }, function() { |
35 testFailed("Promise was rejected."); | 48 testFailed("Promise was rejected."); |
36 finishJSTest(); | 49 finishJSTest(); |
37 }); | 50 }); |
38 } | 51 } |
| 52 |
| 53 function asyncTest() { |
| 54 debug("Check the imageBitmap of webgl in the next frame.") |
| 55 var webgl_canvas = document.getElementById("webgl"); |
| 56 createImageBitmapAndCheck(webgl_canvas).then(function() { |
| 57 finishJSTest(); |
| 58 }); |
| 59 } |
39 </script> | 60 </script> |
40 </body> | 61 </body> |
41 </html> | 62 </html> |
OLD | NEW |