Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script>
// Navigating an out-of-process parent unloads descendants hosted by other processes before
// activating the new document.
promiseTest(async () => {
const httpServer = httpTestServer();
const childUrl = new URL(
await httpServer.createEcho("GET", "/oop-nav-child", {
status: 200,
headers: { "Content-Type": "text/html" },
body: `<!DOCTYPE html><script>
addEventListener("unload", () => { document.cookie = "unloadPing=1; path=/; SameSite=None; Secure"; });
document.cookie = "loaded=1; path=/; SameSite=None; Secure";
<\/script>`,
})
);
childUrl.hostname = uniqueLocalhostHostname("oop-nav-child");
const parentHostname = uniqueLocalhostHostname("oop-nav-parent");
const nextParentUrl = new URL(
await httpServer.createEcho("GET", "/oop-nav-parent-next", {
status: 200,
headers: { "Content-Type": "text/html" },
body: `<!DOCTYPE html><script>document.cookie = "committed=1; path=/; SameSite=None; Secure";<\/script>`,
})
);
nextParentUrl.hostname = parentHostname;
// Add the child after the parent is showing so the test does not depend on propagating the remote child's
// load event before it can initiate the parent navigation. The parent navigates when told to, once this
// document has seen the child hosted out of process.
const parentUrl = new URL(
await httpServer.createEcho("GET", "/oop-nav-parent", {
status: 200,
headers: { "Content-Type": "text/html" },
body: `<!DOCTYPE html><script>
addEventListener("message", () => { location.href = "${nextParentUrl}"; });
addEventListener("load", () => {
document.cookie = "shown=1; path=/; SameSite=None; Secure";
const frame = document.createElement("iframe");
frame.src = "${childUrl}";
document.body.appendChild(frame);
});
<\/script>`,
})
);
parentUrl.hostname = parentHostname;
const frame = document.createElement("iframe");
frame.src = parentUrl;
document.body.appendChild(frame);
if (!await waitForCondition(() => remoteFrameCount() >= 2)) {
println("remote frame setup did not complete");
return;
}
if (!await waitForCondition(() => internals.hasCookieForURL(parentUrl.href, "shown", "1") && internals.hasCookieForURL(childUrl.href, "loaded", "1"))) {
println("remote document setup did not complete");
return;
}
frame.contentWindow.postMessage("navigate", "*");
for (const [url, name, value, description] of [
[childUrl, "unloadPing", "1", "remote child unload handler"],
[nextParentUrl, "committed", "1", "parent navigation"],
]) {
if (!await waitForCondition(() => internals.hasCookieForURL(url.href, name, value))) {
println(`${description} did not complete`);
return;
}
println(`${description} completed`);
}
});
</script>