OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <canvas id="canvas" width="3" height="2"></canvas> | 4 <canvas id="canvas" width="3" height="2"></canvas> |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/js-test.js"></script> |
6 <script> | 6 <script> |
7 jsTestIsAsync = true; | 7 jsTestIsAsync = true; |
8 var worker = new Worker('./resources/canvas-ImageBitmap-transferable.js'); | 8 var worker = new Worker('./resources/canvas-ImageBitmap-transferable.js'); |
9 | 9 |
10 description("Tests that ImageBitmap is transferable and that the pixel data surv
ives the trip, as well as createImageBitmap(ImageBitmap) works on worker thread"
); | 10 description("Tests that ImageBitmap is transferable and that the pixel data surv
ives the trip, as well as createImageBitmap(ImageBitmap) works on worker thread"
); |
(...skipping 21 matching lines...) Expand all Loading... |
32 shouldBe("bitmapHeight", "imageHeight"); | 32 shouldBe("bitmapHeight", "imageHeight"); |
33 | 33 |
34 worker.postMessage({data: imageBitmap}, [imageBitmap]); | 34 worker.postMessage({data: imageBitmap}, [imageBitmap]); |
35 | 35 |
36 // ImageBitmap has been transfered to worker, main thread loses ownership | 36 // ImageBitmap has been transfered to worker, main thread loses ownership |
37 // of it, so the width and height should be 0 now. | 37 // of it, so the width and height should be 0 now. |
38 bitmapWidth = imageBitmap.width; | 38 bitmapWidth = imageBitmap.width; |
39 bitmapHeight = imageBitmap.height; | 39 bitmapHeight = imageBitmap.height; |
40 shouldBe("bitmapWidth", "0"); | 40 shouldBe("bitmapWidth", "0"); |
41 shouldBe("bitmapHeight", "0"); | 41 shouldBe("bitmapHeight", "0"); |
| 42 |
| 43 newImageBitmap = imageBitmap; |
| 44 // Test createImageBitmap from neutered ImageBitmap |
| 45 createImageBitmap(imageBitmap).then(function() { |
| 46 testFailed("Promise accepted, expected to be rejected"); |
| 47 finishJSTest(); |
| 48 }, () => { |
| 49 testPassed("createImageBitmap from a neutered ImageBitmap was rejected"); |
| 50 }); |
42 }); | 51 }); |
43 | 52 |
44 worker.onmessage = function(e) { | 53 worker.onmessage = function(e) { |
45 newImageBitmap = e.data.data; | 54 newImageBitmap = e.data.data; |
46 bitmapWidth = newImageBitmap.width; | 55 bitmapWidth = newImageBitmap.width; |
47 bitmapHeight = newImageBitmap.height; | 56 bitmapHeight = newImageBitmap.height; |
48 | 57 |
49 // Getting the ImageBitmap back from the worker thread | 58 // Getting the ImageBitmap back from the worker thread |
50 shouldBe("bitmapWidth", "imageWidth"); | 59 shouldBe("bitmapWidth", "imageWidth"); |
51 shouldBe("bitmapHeight", "imageHeight"); | 60 shouldBe("bitmapHeight", "imageHeight"); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 shouldBeCloseTo("newImage.data[20]", "image.data[20]", 5); | 94 shouldBeCloseTo("newImage.data[20]", "image.data[20]", 5); |
86 shouldBeCloseTo("newImage.data[21]", "image.data[21]", 5); | 95 shouldBeCloseTo("newImage.data[21]", "image.data[21]", 5); |
87 shouldBeCloseTo("newImage.data[22]", "image.data[22]", 5); | 96 shouldBeCloseTo("newImage.data[22]", "image.data[22]", 5); |
88 shouldBe("newImage.data[23]", "image.data[23]"); | 97 shouldBe("newImage.data[23]", "image.data[23]"); |
89 finishJSTest(); | 98 finishJSTest(); |
90 } | 99 } |
91 | 100 |
92 </script> | 101 </script> |
93 </body> | 102 </body> |
94 </html> | 103 </html> |
OLD | NEW |