OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 </head> |
| 7 <body> |
| 8 <script> |
| 9 async_test(function(t) { |
| 10 var canvas = document.createElement('canvas'); |
| 11 var offscreen = canvas.transferControlToOffscreen(); |
| 12 var ctx = offscreen.getContext('2d'); |
| 13 ctx.fillStyle = '#0f0'; |
| 14 ctx.fillRect(0, 0, canvas.width, canvas.height); |
| 15 ctx.commit(); |
| 16 |
| 17 var testCanvas = document.createElement('canvas'); |
| 18 var testCtx = testCanvas.getContext('2d'); |
| 19 |
| 20 createImageBitmap(canvas).then(image => { |
| 21 testCtx.drawImage(image, 0, 0); |
| 22 t.step( function() { |
| 23 var pixel = testCtx.getImageData(0, 0, 1, 1).data; |
| 24 var expectedValue = [0, 0, 0, 0]; // pixel is blank because commit() is as
ync |
| 25 assert_array_equals(pixel, expectedValue, "Verify that commit() is not syn
chronous."); |
| 26 }); |
| 27 |
| 28 // The call to setTimeout acts as a synchronization barrier to guarantee tha
t |
| 29 // the commit has propagated. |
| 30 setTimeout(function() { |
| 31 createImageBitmap(canvas).then(image => { |
| 32 testCtx.drawImage(image, 0, 0); |
| 33 t.step( function() { |
| 34 var pixel = testCtx.getImageData(0, 0, 1, 1).data; |
| 35 var expectedValue = [0, 255, 0, 255]; |
| 36 assert_array_equals(pixel, expectedValue, "Verify that async update of
placeholder propagated through createImageData"); |
| 37 }); |
| 38 t.done(); |
| 39 }); |
| 40 }, 0); |
| 41 }); |
| 42 }, "Test whether createImageBitmap on a placeholder canvas captures the image co
mmitted to the associated OffscreenCanvas."); |
| 43 </script> |
| 44 </body> |
| 45 </html> |
OLD | NEW |