Restrict security origin inheritance to empty, about:blank, and about:srcdoc URLs
[WebKit-https.git] / LayoutTests / http / tests / dom / window-open-about-webkit-org-and-access-document.html
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4     <title>Tests opening a new about://webkit.org window and accessing its document</title>
5     <script src="../resources/js-test-pre.js"></script>
6     <script>
7         var newWindow;
8
9         if (window.testRunner) {
10             testRunner.setCanOpenWindows();
11             testRunner.waitUntilDone();
12         }
13
14         function checkNewWindowDocumentIsUndefined () {
15             shouldBeUndefined("newWindow.document");
16             if (window.testRunner)
17                 testRunner.notifyDone();
18         }
19
20         function clickHandler() {
21             newWindow = window.open("about://webkit.org");
22             try {
23                 newWindow.document.write("<scri" + "pt>console.log('Injected script running.')</sc" + "ript>");
24                 testFailed("Was able to write to the new window's document.");
25                 if (window.testRunner)
26                     testRunner.notifyDone();
27             } catch (e) {
28                 setTimeout(checkNewWindowDocumentIsUndefined, 500);
29             }
30         }
31
32         function clickButton() {
33             var button = document.getElementById("test");
34             var buttonX = button.offsetLeft + button.offsetWidth / 2;
35             var buttonY = button.offsetTop + button.offsetHeight / 2;
36             if (window.eventSender) {
37                 eventSender.mouseMoveTo(buttonX, buttonY);
38                 eventSender.mouseDown();
39                 eventSender.mouseUp();
40             }
41         }
42     </script>
43 </head>
44 <body onload="clickButton()">
45 <button id="test" onclick="clickHandler()"></button>
46 <div id="console"></div>
47 </body>
48 </html>