summaryrefslogtreecommitdiffstats
path: root/docshell/test/mochitest/test_iframe_srcdoc_to_remote.html
blob: 05e0934d50917bdf2def0eaacbe3f484d393cacc (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
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<head>
  <meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
</head>

<body onload="test()">
    <script>
        /*
         Test to verify that when we change an OOP iframe to one that has a
         srcdoc it loads in the correct process, which in this case is this
         test document.
         */
        SimpleTest.waitForExplicitFinish();
        async function test() {
            // Create an OOP iframe
            let frame = document.createElement("iframe");
            await new Promise(r => {
                frame.onload = r;
                document.body.appendChild(frame);
                // eslint-disable-next-line @microsoft/sdl/no-insecure-url
                frame.contentWindow.location = "http://example.net/tests/docshell/test/dummy_page.html";
            });
            if (SpecialPowers.useRemoteSubframes) {
              ok(SpecialPowers.Cu.isRemoteProxy(frame.contentWindow), "should be a remote frame");
            }

            // Remove the attribute so we can set a srcdoc attribute on it
            frame.removeAttribute("src");

            // Set a srcdoc attribute on this iframe and wait for the load
            await new Promise(r => {
                frame.onload = r;
                frame.setAttribute("srcdoc", '<html><body>body of the srcdoc frame</body></html>');
            });

            // We should be in the same process as this test document
            ok(!SpecialPowers.Cu.isRemoteProxy(frame.contentWindow), "should NOT be a remote frame");
            SimpleTest.finish();
        }
    </script>
</body>