OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <body> |
| 4 <script src="/js-test-resources/js-test.js"></script> |
| 5 <script> |
| 6 description("WebGL's tex(Sub)Image2D should throw a SecurityError exception when
the ImageBitmap is not origin clean."); |
| 7 |
| 8 window.jsTestIsAsync = true; |
| 9 var gl; |
| 10 var bitmap; |
| 11 |
| 12 var image = document.createElement('img'); |
| 13 image.src = 'http://localhost:8080/security/resources/abe.png'; |
| 14 |
| 15 image.addEventListener('load', function() { |
| 16 var canvas = document.createElement("canvas"); |
| 17 canvas.width = 10; |
| 18 canvas.height = 10; |
| 19 |
| 20 gl = canvas.getContext("webgl"); |
| 21 var texture = gl.createTexture(); |
| 22 shouldBe("gl.getError()", "gl.NO_ERROR"); |
| 23 gl.bindTexture(gl.TEXTURE_2D, texture); |
| 24 shouldBe("gl.getError()", "gl.NO_ERROR"); |
| 25 |
| 26 // ImageBitmap created from a clean canvas should be origin clean |
| 27 createImageBitmap(canvas, 0, 0, 10, 10).then(imageBitmap => { |
| 28 bitmap = imageBitmap; |
| 29 shouldNotThrow("gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNS
IGNED_BYTE, bitmap)"); |
| 30 shouldBe("gl.getError()", "gl.NO_ERROR"); |
| 31 shouldNotThrow("gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNS
IGNED_BYTE, bitmap)"); |
| 32 shouldBe("gl.getError()", "gl.NO_ERROR"); |
| 33 |
| 34 // Test tainted ImageBitmap |
| 35 createImageBitmap(image, 0, 0, 10, 10).then(imageBitmap => { |
| 36 bitmap = imageBitmap; |
| 37 shouldThrow("gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UN
SIGNED_BYTE, bitmap)"); |
| 38 shouldBe("gl.getError()", "gl.NO_ERROR"); |
| 39 shouldThrow("gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UN
SIGNED_BYTE, bitmap)"); |
| 40 shouldBe("gl.getError()", "gl.NO_ERROR"); |
| 41 finishJSTest(); |
| 42 }, () => { |
| 43 testFailed("Unexpected failure"); |
| 44 finishJSTest(); |
| 45 }); |
| 46 }, () => { |
| 47 testFailed("Unexpected failure"); |
| 48 finishJSTest(); |
| 49 }); |
| 50 }); |
| 51 </script> |
| 52 </body> |
| 53 </html> |
OLD | NEW |