Chromium Code Reviews| 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 * crbug.com/438986 | |
| 10 * window.createImageBitmap(HTMLCanvasElement) copies the back buffer of WebGL. | |
| 11 * So createImageBitmap(HTMLCanvasElement) must create transparent ImageBuffer | |
| 12 * 1 frame after WebGL draws contents. | |
| 13 */ | |
| 7 window.jsTestIsAsync = true; | 14 window.jsTestIsAsync = true; |
| 8 | 15 |
| 9 var canvas = document.createElement("canvas"); | 16 var canvas = document.createElement("canvas"); |
| 10 canvas.width = 200; | 17 canvas.width = 200; |
| 11 canvas.height = 200; | 18 canvas.height = 200; |
| 12 var ctx = canvas.getContext("2d"); | 19 var ctx = canvas.getContext("2d"); |
| 13 function shouldBeGreen(x, y) { | 20 function shouldBeGreen(x, y) { |
| 14 d = ctx.getImageData(x, y, 1, 1).data; | 21 d = ctx.getImageData(x, y, 1, 1).data; |
| 15 shouldBeTrue("d[0] == 0"); | 22 shouldBeTrue("d[0] == 0"); |
| 16 shouldBeTrue("d[1] == 255"); | 23 shouldBeTrue("d[1] == 255"); |
| 17 shouldBeTrue("d[2] == 0"); | 24 shouldBeTrue("d[2] == 0"); |
| 18 shouldBeTrue("d[3] == 255"); | 25 shouldBeTrue("d[3] == 255"); |
| 19 } | 26 } |
| 20 | 27 |
| 21 function start() { | 28 function start() { |
| 22 var aCanvas = document.createElement("canvas"); | 29 debug("Check the imageBitmap of webgl.") |
| 23 aCanvas.width = 200; | 30 var webgl_canvas = document.getElementById("webgl"); |
| 24 aCanvas.height = 200; | 31 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); | 32 gl.clearColor(0.0, 1.0, 0.0, 1.0); |
| 27 gl.clear(gl.COLOR_BUFFER_BIT); | 33 gl.clear(gl.COLOR_BUFFER_BIT); |
| 34 createImageBitmapAndCheck(webgl_canvas).then(function() { | |
| 35 if (window.testRunner) { | |
| 36 testRunner.displayAsyncThen(asyncTest); | |
| 37 } else { | |
| 38 window.requestAnimationFrame(asyncTest); | |
| 39 } | |
| 40 }); | |
| 41 } | |
| 28 | 42 |
| 29 createImageBitmap(aCanvas).then(function (imageBitmap) { | 43 function createImageBitmapAndCheck(webgl_canvas) { |
| 44 return createImageBitmap(webgl_canvas).then(function (imageBitmap) { | |
| 45 ctx.clearRect(0, 0, 200, 200); | |
| 30 ctx.drawImage(imageBitmap, 0, 0); | 46 ctx.drawImage(imageBitmap, 0, 0); |
| 31 shouldBeGreen(50, 50); | 47 shouldBeGreen(50, 50); |
| 32 shouldBeGreen(150, 150); | 48 shouldBeGreen(150, 150); |
| 33 finishJSTest(); | |
| 34 }, function() { | 49 }, function() { |
| 35 testFailed("Promise was rejected."); | 50 testFailed("Promise was rejected."); |
| 36 finishJSTest(); | 51 finishJSTest(); |
| 37 }); | 52 }); |
| 38 } | 53 } |
| 54 | |
| 55 function asyncTest() { | |
| 56 debug("Check the imageBitmap of webgl in the next frame. It must fail.") | |
|
Ken Russell (switch to Gerrit)
2014/12/11 01:35:56
Please rephrase this test so that the expectations
| |
| 57 var webgl_canvas = document.getElementById("webgl"); | |
| 58 createImageBitmapAndCheck(webgl_canvas).then(function() { | |
| 59 finishJSTest(); | |
| 60 }); | |
| 61 } | |
| 39 </script> | 62 </script> |
| 40 </body> | 63 </body> |
| 41 </html> | 64 </html> |
| OLD | NEW |