<!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>

