<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
description("Tests proper tear-down of shadow content.");

window.jsTestIsAsync = true;

var target;
var shadow;
var childFrame;

function runTest() {
    target = document.body.appendChild(document.createElement("div"));
    shadow = target.attachShadow({mode: "open"});

    childFrame = shadow.appendChild(document.createElement("iframe"));

    childFrame.onload = () => {
        childFrame.onload = null;

        childFrame.src = "javascript:alert(window.location.toString().includes('about:blank'))";

        var xml = `
<svg xmlns="http://www.w3.org/2000/svg">
<script>
document.documentElement.appendChild(parent.target);
</sc` + `ript>
<text x="10" y="20">PASS</text>
<script>
parent.pass();
</sc` + `ript>
</svg>`;

        var innerFrame = document.body.appendChild(document.createElement("iframe"));
        innerFrame.src = URL.createObjectURL(new Blob([xml], {type: "text/xml"}));
    };

    childFrame.src = "resources/start.html";
}

function pass() {
    testPassed("Passes if the second alert is 'true'.");
    finishJSTest();
}
</script>
</head>
<body onload="runTest()">
</body>
</html>