OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/testharness.js"></script> | 2 <script src="../../../resources/testharness.js"></script> |
3 <script src="../../../resources/testharnessreport.js"></script> | 3 <script src="../../../resources/testharnessreport.js"></script> |
4 <script> | 4 <script> |
5 async_test(t => { | 5 async_test(t => { |
6 var image = new Image(); | 6 var image = new Image(); |
7 // Notice that we don't set the image.crossOrigin property. | 7 // Notice that we don't set the image.crossOrigin property. |
8 image.src = "http://localhost:8000/security/resources/abe-allow-star.php"; | 8 image.src = "http://localhost:8000/security/resources/abe-allow-star.php"; |
9 image.onload = function() { | 9 image.onload = function() { |
10 var canvas = document.createElement('canvas'); | 10 var canvas = document.createElement('canvas'); |
11 canvas.width = canvas.height = 10; | 11 canvas.width = canvas.height = 10; |
12 var offscreen = canvas.transferControlToOffscreen(); | 12 var offscreen = canvas.transferControlToOffscreen(); |
13 var ctx = offscreen.getContext('2d'); | 13 var ctx = offscreen.getContext('2d'); |
14 ctx.drawImage(image, 0, 0); | 14 ctx.drawImage(image, 0, 0); |
15 ctx.commit(); | 15 ctx.commit(); |
16 t.step(function() { | 16 t.step(function() { |
17 canvas.toDataURL(); // Succeeds by not throwing | 17 canvas.toDataURL(); // Succeeds by not throwing |
18 }); | 18 }); |
19 setTimeout(function() { // sync barrier for commit() propagation | 19 // TODO(junov): Use the Promise returned by commit to schedule after the |
20 t.step(function() { | 20 // commit. (crbug.com/709484) |
21 assert_throws("SecurityError", function() { | 21 setTimeout(function() { |
22 canvas.toDataURL(); | 22 setTimeout(function() { |
23 }, "Check toDataURL blocked."); | |
24 }); | |
25 ctx.commit(); // Second frame does not reset origin-clean flag. | |
26 setTimeout(function() { // sync barrier for commit() propagation | |
27 t.step(function() { | 23 t.step(function() { |
28 assert_throws("SecurityError", function() { | 24 assert_throws("SecurityError", function() { |
29 canvas.toDataURL(); | 25 canvas.toDataURL(); |
30 }); | 26 }, "Check toDataURL blocked."); |
31 }); | 27 }); |
32 t.done(); | 28 ctx.commit(); // Second frame does not reset origin-clean flag. |
| 29 // TODO(junov): Use the Promise returned by commit to schedule after the |
| 30 // commit. (crbug.com/709484) |
| 31 setTimeout(function() { |
| 32 setTimeout(function() { |
| 33 t.step(function() { |
| 34 assert_throws("SecurityError", function() { |
| 35 canvas.toDataURL(); |
| 36 }); |
| 37 }); |
| 38 t.done(); |
| 39 }, 0); |
| 40 }, 0); |
33 }, 0); | 41 }, 0); |
34 }, 0); | 42 }, 0); |
35 } | 43 } |
36 }, "Verify that the placeholder <canvas> associated with an OffscreenCanvas tain
ted with cross-origin content cannot be read once commit has propagated."); | 44 }, "Verify that the placeholder <canvas> associated with an OffscreenCanvas tain
ted with cross-origin content cannot be read once commit has propagated."); |
37 </script> | 45 </script> |
OLD | NEW |