OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset="utf-8"> |
| 3 <title>Canvas's ImageBitmapRenderingContext test</title> |
| 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#the
-imagebitmap-rendering-context"> |
| 7 <script> |
| 8 var width = 10; |
| 9 var height = 10; |
| 10 |
| 11 promise_test(function() { |
| 12 function testException(image) { |
| 13 var dstCanvas = document.createElement('canvas'); |
| 14 dstCanvas.width = width; |
| 15 dstCanvas.height = height; |
| 16 var dstCtx = dstCanvas.getContext('bitmaprenderer'); |
| 17 dstCtx.transferFromImageBitmap(image); |
| 18 |
| 19 // The image should be detached after transferFromImageBitmap. |
| 20 assert_equals(image.width, 0); |
| 21 assert_equals(image.height, 0); |
| 22 assert_throws("InvalidStateError", function() { dstCtx.transferFromImage
Bitmap(image); }); |
| 23 } |
| 24 |
| 25 var srcCanvas = document.createElement('canvas'); |
| 26 srcCanvas.width = width; |
| 27 srcCanvas.height = height; |
| 28 var ctx = srcCanvas.getContext('2d'); |
| 29 ctx.fillStyle = 'rgba(0, 255, 0, 0.5)'; |
| 30 ctx.fillRect(0, 0, width, height); |
| 31 createImageBitmap(srcCanvas).then(testException); |
| 32 }, "Test transferFromImageBitmap(image) with a detached image should throw Inval
idStateError"); |
| 33 |
| 34 </script> |
OLD | NEW |