1 <pre id=
"console"></pre>
3 if (window
.testRunner
) {
4 testRunner
.dumpAsText();
5 testRunner
.waitUntilDone();
10 document
.getElementById('console').appendChild(document
.createTextNode(msg
+ "\n"));
14 var url
= "http://localhost:8000/security/resources/abe-allow-star.php";
16 function testGetImageData(shouldWork
)
18 var canvas
= document
.createElement("canvas");
21 var context
= canvas
.getContext("2d");
22 context
.drawImage(image
, 0, 0, 100, 100);
25 context
.getImageData(0, 0, 100, 100);
29 if (worked
== shouldWork
) {
31 log("PASS: image did not taint canvas");
33 log("PASS: image tainted canvas");
37 log("FAIL: image tainted canvas");
39 log("FAIL: image did not taint canvas");
44 function testWithoutCORS()
46 log("Testing uploading without CORS headers");
47 testGetImageData(false);
49 image
.onload
= testWithCORS
;
50 image
.crossOrigin
= "";
54 function testWithCORS()
56 log("Testing uploading with CORS headers");
57 testGetImageData(true);
58 if (window
.testRunner
)
59 testRunner
.notifyDone();
64 log('Test that if an image is served with "Access-Control-Allow-Origin: *", then loading it first without and then with a CORS request works the second time.');
66 image
.onload
= testWithoutCORS
;