OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <script src="../../resources/testharness.js"></script> | |
3 <script src="../../resources/testharnessreport.js"></script> | |
4 <script> | |
5 | |
6 function verifyOffscreenCanvasTaintedThenDone(offscreen, t) { | |
7 assert_throws("SecurityError", function() { | |
8 offscreen.getContext("2d").getImageData(0, 0, 1, 1); | |
9 }, "Check getImageData blocked."); | |
10 offscreen.convertToBlob().then( | |
11 function() { | |
12 assert_unreached("Promise returned by convertToBlob was resolved."); | |
13 t.done(); | |
14 }, | |
15 rejectionValue => { | |
16 assert_equals(rejectionValue.name, "SecurityError"); | |
17 t.done(); | |
18 } | |
19 ); | |
20 } | |
21 | |
22 async_test(t => { | |
23 var image = new Image(); | |
24 // Notice that we don't set the image.crossOrigin property. | |
25 image.src = "http://localhost:8000/security/resources/abe-allow-star.php"; | |
26 image.onload = function() { | |
27 var offscreen = new OffscreenCanvas(10, 10); | |
28 var ctx = offscreen.getContext('2d'); | |
29 ctx.drawImage(image, 0, 0); | |
30 t.step(function() { | |
31 verifyOffscreenCanvasTaintedThenDone(offscreen, t); | |
32 }); | |
33 } | |
34 }, "Verify that an OffscreenCanvas tainted with cross-origin content cannot be r ead."); | |
35 | |
36 async_test(t => { | |
37 var image = new Image(); | |
38 // Notice that we don't set the image.crossOrigin property. | |
39 image.src = "http://localhost:8000/security/resources/abe-allow-star.php"; | |
40 image.onload = function() { | |
41 var offscreen = new OffscreenCanvas(10, 10); | |
42 var ctx = offscreen.getContext('2d'); | |
43 ctx.drawImage(image, 0, 0); | |
44 createImageBitmap(offscreen).then(imageBitmap => { | |
45 var offscreen2 = new OffscreenCanvas(10, 10); | |
46 var ctx2 = offscreen2.getContext('2d'); | |
47 ctx2.drawImage(imageBitmap, 0, 0); | |
48 t.step(function() { | |
49 verifyOffscreenCanvasTaintedThenDone(offscreen, t); | |
50 }); | |
51 }) | |
52 } | |
53 }, "Verify that createImageBitmap(OffscreenCanvas) propagates th origin-clean fl ag."); | |
Stephen White
2016/12/12 19:55:46
Nit: th -> the
| |
54 | |
55 | |
56 | |
57 | |
58 | |
59 </script> | |
OLD | NEW |