summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/siteIdentity/test_web_controlled_blank.html
blob: 35c1fd4ca264170d72f46bf23c70eafad8b23231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!doctype html>
<html>
    <head>
        <title>Bug 1813463: Web controlled about:blank</title>
    </head>
    <!--
      This work is marked with CC0 1.0. To view a copy of this license,
      visit http://creativecommons.org/publicdomain/zero/1.0
    -->
    <body>
        <p><a href="#" id="document_write">document.write example</a></p>
        <p><a href="#" id="innerhtml">innerHTML example</a></p>

        <script>
            document.getElementById("document_write").addEventListener("click", function (aEvent) {
                aEvent.preventDefault();
                let popup = window.open("about:blank", "_blank", "width=800,height=600,popup");
                popup.document.write(`
                    <h1>check security info</h1>
                    <p>initial window.location = ${popup.location}</p>
                    <script>
                        document.write("<p>new window.location = " + window.location + "</p>")
                    <${"/"}script>
                    `);
            });
            document.getElementById("innerhtml").addEventListener("click", function (aEvent) {
                aEvent.preventDefault();
                let popup = window.open("about:blank", "_blank", "width=800,height=600,popup");
                popup.stop();
                popup.document.body.innerHTML = `
                    <h1>check security info</h1>
                    <p>window.location = ${popup.location}</p>`;
            });
        </script>
    </body>
</html>