OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script id="myWorker" type="text/worker"> |
| 7 self.onmessage = function(e) { |
| 8 postMessage(e.data); |
| 9 }; |
| 10 </script> |
| 11 <script> |
| 12 async_test(function(t) { |
| 13 function makeWorker(script) { |
| 14 var blob = new Blob([script]); |
| 15 return new Worker(URL.createObjectURL(blob)); |
| 16 } |
| 17 var worker = makeWorker(document.getElementById('myWorker').textContent); |
| 18 var returnedBitmap; |
| 19 |
| 20 var image = new Image(); |
| 21 image.onload = function() { |
| 22 shouldBeTainted(image); |
| 23 createImageBitmap(image).then(imageBitmap => { |
| 24 worker.postMessage({data:imageBitmap}, [imageBitmap]); |
| 25 worker.onmessage = t.step_func(onMessage); |
| 26 }); |
| 27 } |
| 28 image.src = 'http://localhost:8080/security/resources/abe.png'; |
| 29 |
| 30 function onMessage(e) { |
| 31 returnedBitmap = e.data.data; |
| 32 shouldBeTainted(returnedBitmap); |
| 33 t.done(); |
| 34 } |
| 35 |
| 36 function shouldBeTainted(imageBitmap) { |
| 37 var canvas = document.createElement("canvas"); |
| 38 canvas.width = 10; |
| 39 canvas.height = 10; |
| 40 var context = canvas.getContext("2d"); |
| 41 context.drawImage(imageBitmap, 0, 0, 10, 10); |
| 42 assert_throws(null, function () { context.getImageData(0, 0, 10, 10); },
'ImageBitmap should be tainted'); |
| 43 } |
| 44 }, 'Transfer and structured-clone an ImageBitmap should preserve the originClean
flag.'); |
| 45 </script> |
| 46 </body> |
| 47 </html> |
OLD | NEW |