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