OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Test using a placeholder canvas as an image source.</title> | 2 <title>Test using a placeholder canvas as an image source.</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 | 5 |
6 <script id='myWorker' type='text/worker'> | 6 <script id='myWorker' type='text/worker'> |
7 var ctx; | 7 var ctx; |
8 self.onmessage = function(msg) { | 8 self.onmessage = function(msg) { |
9 ctx = msg.data.getContext('2d'); | 9 ctx = msg.data.getContext('2d'); |
10 ctx.fillStyle = '#0f0'; | 10 ctx.fillStyle = '#0f0'; |
11 ctx.fillRect(0, 0, 100, 100); | 11 ctx.fillRect(0, 0, 100, 100); |
12 ctx.commit(); | 12 var p = ctx.commit(); |
13 | 13 |
14 self.postMessage("done"); | 14 p.then(function() { |
| 15 self.postMessage("done"); |
| 16 }); |
15 }; | 17 }; |
16 </script> | 18 </script> |
17 | 19 |
18 <script> | 20 <script> |
19 var t = async_test("Test that using a placeholder canvas as a source image acces
ses the image that was committed to the associated OffscreenCanvas in a worker."
); | 21 var t = async_test("Test that using a placeholder canvas as a source image acces
ses the image that was committed to the associated OffscreenCanvas in a worker."
); |
20 var canvas = document.createElement('canvas'); | 22 var canvas = document.createElement('canvas'); |
21 canvas.width = 100; | 23 canvas.width = 100; |
22 canvas.height = 100; | 24 canvas.height = 100; |
23 var offscreen = canvas.transferControlToOffscreen(); | 25 var offscreen = canvas.transferControlToOffscreen(); |
24 | 26 |
(...skipping 20 matching lines...) Expand all Loading... |
45 function verifyImage(image, description) { | 47 function verifyImage(image, description) { |
46 var testCanvas = document.createElement('canvas'); | 48 var testCanvas = document.createElement('canvas'); |
47 var testCtx = testCanvas.getContext('2d'); | 49 var testCtx = testCanvas.getContext('2d'); |
48 testCtx.drawImage(image, 0, 0); | 50 testCtx.drawImage(image, 0, 0); |
49 | 51 |
50 t.step(function() { | 52 t.step(function() { |
51 var pixel = testCtx.getImageData(50, 50, 1, 1).data; | 53 var pixel = testCtx.getImageData(50, 50, 1, 1).data; |
52 assert_array_equals(pixel, [0, 255, 0, 255], description); | 54 assert_array_equals(pixel, [0, 255, 0, 255], description); |
53 }); | 55 }); |
54 } | 56 } |
55 </script> | 57 </script> |
OLD | NEW |