Popups opened from a sandboxed iframe should themselves be sandboxed
[WebKit-https.git] / LayoutTests / http / tests / security / window-opened-from-sandboxed-iframe-should-inherit-sandbox.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <meta charset="UTF-8">
5     <title>Tests that windows created from a sandboxed context inherit the same sandbox</title>
6     <script src="../resources/js-test-pre.js"></script>
7 </head>
8 <body>
9 <script>
10     if (window.testRunner) {
11         testRunner.setCanOpenWindows();
12         testRunner.waitUntilDone();
13         testRunner.setPopupBlockingEnabled(false);
14         testRunner.dumpAsText();
15     }
16
17     function wrapUp () {
18         finishJSTest();
19         if (window.testRunner) {
20             testRunner.notifyDone();
21         }
22     }
23
24     function run() {
25         var iframeContentDocument = document.getElementById("theIframe").contentDocument;
26         if (!iframeContentDocument) {
27             testFailed("Can't get iframeElement.contentDocument");
28             finishJSTest();
29             testRunner.notifyDone();
30         } else {
31             var theLink = iframeContentDocument.getElementById("theLink");
32             if (!theLink) {
33                 testFailed("Can't get iframeElement.contentDocument.getElementById('theLink')");
34                 finishJSTest();
35                 testRunner.notifyDone();
36             } else {
37                 var clickEvent = document.createEvent("HTMLEvents");
38                 clickEvent.initEvent("click", true, true);
39                 theLink.dispatchEvent(clickEvent);
40
41                 setTimeout(wrapUp, 500);
42             }
43         }
44     }
45 </script>
46 <iframe onload="run()" id="theIframe" sandbox="allow-same-origin allow-popups" src="resources/anchor-tag-with-blank-target.html"></iframe>
47 </body>
48 </html>