Skip to content

Truly independent web browser

1.4 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
    asyncTest(async done => {
        const server = httpTestServer();
        const scriptURL = await server.createEcho("GET", "/svg-document-external-script-blocks-parser.js", {
            status: 200,
            headers: { "Content-Type": "text/javascript" },
            body: "globalThis.externalScriptExecuted = true;",
        });
        const scriptStartTag = "<scr" + "ipt";
        const scriptEndTag = "</scr" + "ipt>";
        const documentURL = await server.createEcho("GET", "/svg-document-external-script-blocks-parser.svg", {
            status: 200,
            headers: { "Content-Type": "image/svg+xml" },
            body: `<svg xmlns="http://www.w3.org/2000/svg">
                ${scriptStartTag} href="${scriptURL}">${scriptEndTag}
                ${scriptStartTag}>parent.postMessage(globalThis.externalScriptExecuted ? "ran" : "had not run", "*");${scriptEndTag}
            </svg>`,
        });

        window.addEventListener(
            "message",
            event => {
                println(`External script of an SVG document before the following script: ${event.data}`);
                done();
            },
            { once: true }
        );

        const frame = document.createElement("iframe");
        frame.src = documentURL;
        document.body.appendChild(frame);
    });
</script>