4 <meta http-equiv=
"Content-Security-Policy" content=
"img-src 'none'">
6 if (window
.testRunner
) {
7 testRunner
.dumpAsText();
8 testRunner
.waitUntilDone();
12 window
.addEventListener("message", function(message
) {
18 // This is needed because isolated worlds are not reset between test
19 // runs and a previous test's CSP may interfere with this test. See
20 // https://crbug.com/415845.
21 testRunner
.setIsolatedWorldContentSecurityPolicy(1, '');
22 var img
= document
.getElementById('testimg');
23 img
.onload = function () {
25 window
.postMessage("next", "*");
27 img
.onerror = function () {
29 window
.postMessage("next", "*");
35 function setImgSrc(isolated
, num
) {
36 var img
= document
.getElementById('testimg');
37 img
.src
= "../resources/abe.png?" + num
;
40 alert("Running test #" + tests
+ "\n");
46 testRunner
.evaluateScriptInIsolatedWorld(1, String(eval("setImgSrc")) + "\nsetImgSrc(true, 5);");
49 alert("Starting to bypass main world's CSP:");
50 testRunner
.setIsolatedWorldContentSecurityPolicy(1, 'img-src *');
51 testRunner
.evaluateScriptInIsolatedWorld(1, String(eval("setImgSrc")) + "\nsetImgSrc(true, 4);");
54 // Main world, then isolated world -> should load
56 testRunner
.evaluateScriptInIsolatedWorld(1, String(eval("setImgSrc")) + "\nsetImgSrc(true, 3);");
59 // Isolated world, then main world -> should block
60 testRunner
.evaluateScriptInIsolatedWorld(1, String(eval("setImgSrc")) + "\nsetImgSrc(true, 2);");
67 testRunner
.setIsolatedWorldContentSecurityPolicy(1, '');
68 testRunner
.notifyDone();
74 <body onload='setup();'
>
77 This test ensures that scripts run in isolated worlds marked with their
78 own Content Security Policy aren't affected by the page's content
79 security policy. Extensions, for example, should be able to load any