<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>

description('This tests that each data URI document has its own unique event loop');

if (!window.internals)
    testFailed('This test relies on window.internals');
else {
    jsTestIsAsync = true;

    childFrame = document.createElement('iframe');
    document.body.appendChild(childFrame);

    childFrame.src = `data:text/html,<!DOCTYPE html>
    <body onload="parent.postMessage(internals.hasSameEventLoopAs(nestedFrame.contentWindow), '*')">
    <iframe id="nestedFrame" src="data:text/html,<!DOCTYPE html>">`;

    onmessage = (event) => {
        window.nestedFrameWithDataURLHasSameEventLoopAsParent = event.data;
        shouldBeFalse('internals.hasSameEventLoopAs(childFrame.contentWindow)');
        shouldBeFalse('nestedFrameWithDataURLHasSameEventLoopAsParent');
        finishJSTest();
    }
}

successfullyParsed = true;

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
