Skip to content

Truly independent web browser

2.0 KB
Raw Blame
<!doctype html>
<script src="../include.js"></script>
<body>
<div class="used"></div>
<div class="hidden"></div>
<div class="hidden-parent"><div class="in-hidden-subtree"></div></div>
<div class="overridden winner"></div>
<div id="inline-hidden"></div>
<script>
const token = crypto.randomUUID();
const names = ["used", "unmatched", "hidden", "in-hidden-subtree", "overridden", "inline-hidden"];
const pathOf = name => `/echo/css-image-${token}-${name}.png`;
for (const name of names) {
    const request = new XMLHttpRequest();
    request.open("POST", "/echo", false);
    request.setRequestHeader("Content-Type", "application/json");
    request.send(JSON.stringify({
        method: "GET",
        path: pathOf(name),
        status: 200,
        headers: { "Content-Type": "image/png", "Cache-Control": "no-store" },
        body_encoding: "base64",
        body: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
    }));
}

const style = document.createElement("style");
style.textContent = `
    div { width: 10px; height: 10px; }
    .used { background-image: url("${pathOf("used")}"); }
    .unmatched { background-image: url("${pathOf("unmatched")}"); }
    .hidden { display: none; background-image: url("${pathOf("hidden")}"); }
    .hidden-parent { display: none; }
    .in-hidden-subtree { background-image: url("${pathOf("in-hidden-subtree")}"); }
    .overridden { background-image: url("${pathOf("overridden")}"); }
    .overridden.winner { background-image: url("${pathOf("used")}"); }
`;
document.head.append(style);
document.getElementById("inline-hidden").setAttribute("style", `display: none; background-image: url("${pathOf("inline-hidden")}")`);

asyncTest(done => {
    window.addEventListener("load", async () => {
        for (const name of names) {
            const response = await fetch(`/recorded-request-headers${pathOf(name)}`);
            println(`${name} requested: ${response.ok}`);
        }
        done();
    });
});
</script>