| OLD | NEW |
| (Empty) | |
| 1 var EXPECT_BLOCK = true; |
| 2 var EXPECT_LOAD = false; |
| 3 |
| 4 window.jsTestIsAsync = true; |
| 5 window.wasPostTestScriptParsed = true; |
| 6 |
| 7 var iframe; |
| 8 function injectFrame(url, shouldBlock) { |
| 9 window.onload = function () { |
| 10 iframe = document.createElement('iframe'); |
| 11 iframe.onload = iframeLoaded(shouldBlock); |
| 12 iframe.src = url; |
| 13 document.body.appendChild(iframe); |
| 14 }; |
| 15 } |
| 16 |
| 17 function iframeLoaded(expectBlock) { |
| 18 return function(ev) { |
| 19 var failed = true; |
| 20 try { |
| 21 console.log("IFrame load event fired: the IFrame's location is '" +
ev.target.contentWindow.location.href + "'."); |
| 22 if (expectBlock) { |
| 23 testFailed("The IFrame should have been blocked (or cross-origin
). It wasn't."); |
| 24 failed = true; |
| 25 } else { |
| 26 testPassed("The IFrame should not have been blocked. It wasn't."
); |
| 27 failed = false; |
| 28 } |
| 29 } catch (ex) { |
| 30 debug("IFrame load event fired: the IFrame is cross-origin (or was b
locked)."); |
| 31 if (expectBlock) { |
| 32 testPassed("The IFrame should have been blocked (or cross-origin
). It was."); |
| 33 failed = false; |
| 34 } else { |
| 35 testFailed("The IFrame should not have been blocked. It was."); |
| 36 failed = true; |
| 37 } |
| 38 } |
| 39 finishJSTest(); |
| 40 }; |
| 41 } |
| 42 |
| 43 function injectFrameRedirectingTo(url, shouldBlock) { |
| 44 injectFrame("/security/contentSecurityPolicy/resources/redir.php?url=" + url
, shouldBlock); |
| 45 } |
| OLD | NEW |