Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<script>
asyncTest(async done => {
const server = httpTestServer();
const load = async (name, { crossOrigin, headers = {}, credentials = "same-origin" }) => {
const url = new URL(await server.createEcho("GET", `/${name}`, {
status: 200,
headers: { "Content-Type": "text/plain", ...headers },
body: "",
}));
if (crossOrigin)
url.hostname = uniqueLocalhostHostname(name);
try {
await fetch(url, { mode: "no-cors", credentials });
println(`${name}: loaded`);
} catch {
println(`${name}: blocked`);
}
};
// Credentialless omits credentials from cross-origin no-cors requests, so a response without a
// Cross-Origin-Resource-Policy header loads.
await load("cross-origin-without-corp", { crossOrigin: true, credentials: "include" });
await load("cross-origin-with-same-origin-corp", { crossOrigin: true, credentials: "include", headers: { "Cross-Origin-Resource-Policy": "same-origin" } });
done();
});
</script>