| <!DOCTYPE HTML> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script> |
| test(function() { |
| var offscreenCanvas = new OffscreenCanvas(100, 50); |
| var ctx = offscreenCanvas.getContext('2d'); |
| ctx.fillStyle = "#0f0"; |
| ctx.fillRect(0, 0, 100, 50); |
| // The default globalCompositeOperation is source-over, that that will |
| // draw nothing in the next drawImage call. So we have to change it to copy |
| // so that it will actually draw transparent black in the next drawImage |
| // call. |
| ctx.globalCompositeOperation = 'copy'; |
| |
| var offscreenCanvas2 = new OffscreenCanvas(100, 50); |
| ctx.drawImage(offscreenCanvas2, 0, 0); |
| |
| var clr = ctx.getImageData(50, 25, 1, 1).data; |
| assert_array_equals(clr, [0, 0, 0, 0]); |
| }, 'Use OffscreenCanvas without a context as ImageSource should draw transparent black'); |
| </script> |