mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 664299 - Test loading cross-domain images validated with CORS in WebGL. r=bz
This commit is contained in:
parent
ce6238936e
commit
8560e62354
@ -56,4 +56,5 @@ libs:: $(_TEST_FILES)
|
||||
$(TAR) -cf - -C $(srcdir) \
|
||||
resources \
|
||||
conformance \
|
||||
crossorigin \
|
||||
| $(TAR) -xf - -C $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 844 B |
@ -0,0 +1,2 @@
|
||||
Access-Control-Allow-Origin: http://mochi.test:8888
|
||||
Access-Control-Allow-Credentials: true
|
BIN
content/canvas/test/webgl/crossorigin/image-allow-star.png
Normal file
BIN
content/canvas/test/webgl/crossorigin/image-allow-star.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 844 B |
@ -0,0 +1 @@
|
||||
Access-Control-Allow-Origin: *
|
BIN
content/canvas/test/webgl/crossorigin/image.png
Normal file
BIN
content/canvas/test/webgl/crossorigin/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 844 B |
@ -0,0 +1,137 @@
|
||||
<!DOCTYPE HTML>
|
||||
<title>WebGL cross-origin textures test</title>
|
||||
<script src="/MochiKit/MochiKit.js"></script>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
||||
<body>
|
||||
<canvas id="canvas" style="border: none;" width="100" height="100">
|
||||
<p class="fallback"> FAIL (fallback content) </p>
|
||||
</canvas>
|
||||
<script>
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const SECURITY_ERR = 0x805303e8;
|
||||
const OK = 0;
|
||||
|
||||
var gl;
|
||||
var number_of_tests_live = 0;
|
||||
var all_tests_started = false;
|
||||
|
||||
function nameForErrorCode(code) {
|
||||
switch(code) {
|
||||
case OK: return "no error";
|
||||
case SECURITY_ERR: return "security error";
|
||||
}
|
||||
return "unexpected error (" + code + ")";
|
||||
}
|
||||
|
||||
function verifyError(actual_error, expected_error, message) {
|
||||
ok(actual_error == expected_error,
|
||||
message + ": expected " + nameForErrorCode(expected_error)
|
||||
+ ", got " + nameForErrorCode(actual_error));
|
||||
}
|
||||
|
||||
function testTexture(url, crossOriginAttribute, expected_result) {
|
||||
number_of_tests_live++;
|
||||
var image = new Image();
|
||||
if (crossOriginAttribute != "leave-default-crossOrigin-attribute")
|
||||
image.crossOrigin = crossOriginAttribute;
|
||||
|
||||
function testDone() {
|
||||
number_of_tests_live--;
|
||||
|
||||
if (number_of_tests_live == 0 && all_tests_started)
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
image.onload = function() {
|
||||
var tex = gl.createTexture();
|
||||
gl.bindTexture(gl.TEXTURE_2D, tex);
|
||||
var actual_result = OK;
|
||||
try {
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
||||
} catch(e) {
|
||||
actual_result = e.result;
|
||||
}
|
||||
verifyError(actual_result, expected_result, "texImage2D on " + url + " with crossOrigin=" + image.crossOrigin);
|
||||
|
||||
testDone();
|
||||
};
|
||||
|
||||
image.onerror = function(event) {
|
||||
ok(expected_result != OK, "Got an error but expected OK!");
|
||||
|
||||
testDone();
|
||||
}
|
||||
|
||||
image.src = url;
|
||||
}
|
||||
|
||||
MochiKit.DOM.addLoadEvent(function () {
|
||||
var canvas = document.getElementById("canvas");
|
||||
try {
|
||||
gl = canvas.getContext("experimental-webgl");
|
||||
} catch (e) {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
testTexture("http://mochi.test:8888/tests/content/canvas/test/webgl/crossorigin/image.png",
|
||||
"leave-default-crossOrigin-attribute",
|
||||
OK);
|
||||
|
||||
testTexture("http://mochi.test:8888/tests/content/canvas/test/webgl/crossorigin/image.png",
|
||||
"",
|
||||
OK);
|
||||
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image.png",
|
||||
"leave-default-crossOrigin-attribute",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image.png",
|
||||
"",
|
||||
SECURITY_ERR);
|
||||
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-star.png",
|
||||
"leave-default-crossOrigin-attribute",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-star.png",
|
||||
"",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-star.png",
|
||||
"anonymous",
|
||||
OK);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-star.png",
|
||||
"use-credentials",
|
||||
SECURITY_ERR);
|
||||
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-credentials.png",
|
||||
"leave-default-crossOrigin-attribute",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-credentials.png",
|
||||
"",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-credentials.png",
|
||||
"anonymous",
|
||||
OK);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-credentials.png",
|
||||
"use-credentials",
|
||||
OK);
|
||||
|
||||
// Test that bad values for crossorigin="..." are interpreted as default.
|
||||
testTexture("http://mochi.test:8888/tests/content/canvas/test/webgl/crossorigin/image.png",
|
||||
"foobar",
|
||||
OK);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image.png",
|
||||
"foobar",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-star.png",
|
||||
"foobar",
|
||||
SECURITY_ERR);
|
||||
testTexture("http://example.com/tests/content/canvas/test/webgl/crossorigin/image-allow-credentials.png",
|
||||
"foobar",
|
||||
SECURITY_ERR);
|
||||
|
||||
all_tests_started = true;
|
||||
});
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user