Index: third_party/WebKit/LayoutTests/http/tests/security/webgl-cross-origin-ImageBitmap-blocked.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/webgl-cross-origin-ImageBitmap-blocked.html b/third_party/WebKit/LayoutTests/http/tests/security/webgl-cross-origin-ImageBitmap-blocked.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..caae9e4b2896f689714e8aa6ca649da6167c77ed |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/security/webgl-cross-origin-ImageBitmap-blocked.html |
@@ -0,0 +1,44 @@ |
+<!DOCTYPE html> |
+<html> |
+<body> |
+<script src="/js-test-resources/js-test.js"></script> |
+<script> |
+description("WebGL's tex(Sub)Image2D should throw a SecurityError exception when the ImageBitmap is not origin clean."); |
+ |
+window.jsTestIsAsync = true; |
+var gl; |
+var bitmap; |
+ |
+var image = document.createElement('img'); |
+image.src = 'http://localhost:8080/security/resources/abe.png'; |
+ |
+image.addEventListener('load', function() { |
+ var canvas = document.createElement("canvas"); |
+ canvas.width = 10; |
+ canvas.height = 10; |
+ |
+ // ImageBitmap created from a clean canvas should be origin clean |
+ createImageBitmap(canvas, 0, 0, 10, 10).then(imageBitmap => { |
+ bitmap = imageBitmap; |
+ shouldNotThrow("gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmap)"); |
Ken Russell (switch to Gerrit)
2016/01/12 05:03:22
Follow this up with shouldBe("gl.getError()", "gl.
xidachen
2016/01/12 13:58:37
Acknowledged.
|
+ shouldNotThrow("gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, bitmap)"); |
Ken Russell (switch to Gerrit)
2016/01/12 05:03:22
Same here.
xidachen
2016/01/12 13:58:37
Acknowledged.
|
+ }, () => { |
+ testFailed("Unexpected failure"); |
+ finishJSTest(); |
+ }); |
+ |
+ // Testing tainted ImageBitmap |
+ gl = canvas.getContext("webgl"); |
Ken Russell (switch to Gerrit)
2016/01/12 05:03:22
You should create a texture object and bind it to
xidachen
2016/01/12 13:58:37
Acknowledged.
|
+ createImageBitmap(image, 0, 0, 10, 10).then(imageBitmap => { |
+ bitmap = imageBitmap; |
+ shouldThrow("gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, bitmap)"); |
Ken Russell (switch to Gerrit)
2016/01/12 05:03:22
Follow this up with shouldBe("gl.getError()", "gl.
xidachen
2016/01/12 13:58:37
Acknowledged.
|
+ shouldThrow("gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, bitmap)"); |
Ken Russell (switch to Gerrit)
2016/01/12 05:03:22
Same here.
xidachen
2016/01/12 13:58:37
Acknowledged.
|
+ finishJSTest(); |
+ }, () => { |
+ testFailed("Unexpected failure"); |
+ finishJSTest(); |
+ }); |
Ken Russell (switch to Gerrit)
2016/01/12 05:03:22
Shouldn't this entire second createImageBitmap cal
xidachen
2016/01/12 13:58:37
Acknowledged.
|
+}); |
+</script> |
+</body> |
+</html> |