1 var EXPECT_BLOCK = true;
2 var EXPECT_LOAD = false;
4 window.jsTestIsAsync = true;
5 window.wasPostTestScriptParsed = true;
8 function injectFrame(url, shouldBlock) {
9 window.onload = function () {
10 iframe = document.createElement('iframe');
11 iframe.onload = iframeLoaded(shouldBlock);
13 document.body.appendChild(iframe);
17 function iframeLoaded(expectBlock) {
21 console.log("IFrame load event fired: the IFrame's location is '" + ev.target.contentWindow.location.href + "'.");
23 testFailed("The IFrame should have been blocked (or cross-origin). It wasn't.");
26 testPassed("The IFrame should not have been blocked. It wasn't.");
30 debug("IFrame load event fired: the IFrame is cross-origin (or was blocked).");
32 testPassed("The IFrame should have been blocked (or cross-origin). It was.");
35 testFailed("The IFrame should not have been blocked. It was.");
43 function injectFrameRedirectingTo(url, shouldBlock) {
44 injectFrame("/security/contentSecurityPolicy/resources/redir.php?url=" + url, shouldBlock);
47 function injectWorker(url, expectBlock) {
48 window.onload = function() {
49 if (expectBlock == EXPECT_BLOCK)
50 shouldThrow("var w = new Worker('" + url + "');");
52 shouldNotThrow("var w = new Worker('" + url + "');");
57 function injectSharedWorker(url, expectBlock) {
58 window.onload = function() {
59 if (expectBlock == EXPECT_BLOCK)
60 shouldThrow("var w = new SharedWorker('" + url + "');");
62 shouldNotThrow("var w = new SharedWorker('" + url + "');");