info("popup blank.html loaded");
let tell_opener = new URL("file_tell_opener.html", location.href);
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
let xorigin_url = new URL(tell_opener.pathname, "https://example.com");
let resolveStartedUnload;
let startedUnload = new Promise(resolve => {
resolveStartedUnload = resolve;
});
let didFinishUnload = false;
let finishUnload = false;
popup.addEventListener("unload", function() {
resolveStartedUnload();
try {
// Spin a nested event loop in unload until we set `finishUnload`.
SpecialPowers.Services.tm.spinEventLoopUntil( "Test(test_switch_back_nested.html)", () => finishUnload);
} finally {
info("exiting from unload nested event loop...");
didFinishUnload = true;
}
});
info("wait for message from popup");
let messagePromise = new Promise(resolve => {
addEventListener("message", () => {
resolve();
}, { once: true });
});
popup.location = xorigin_url.href;
await messagePromise;
info("popup loaded, ensuring we're in unload");
await startedUnload;
is(didFinishUnload, false, "unload shouldn't have finished");
let switchStarted = SpecialPowers.spawnChrome([], async () => {
await new Promise(resolve => {
async function observer(subject, topic) {
is(topic, "http-on-examine-response");
let uri = subject.QueryInterface(Ci.nsIChannel).URI;
if (!uri.filePath.endsWith("file_tell_opener.html")) {
return;
}
// spin the event loop a few times to ensure we resolve after the process switch
for (let i = 0; i < 10; ++i) {
await new Promise(res => Services.tm.dispatchToMainThread(res));
}
info("Navigating back to the current process");
await SpecialPowers.spawn(popup, [tell_opener.href], (href) => {
content.location.href = href;
});
let messagePromise2 = new Promise(resolve => {
addEventListener("message", () => {
resolve();
}, { once: true });
});
info("Waiting for the process switch to start");
await switchStarted;
// Finish unloading, and wait for the unload to complete
is(didFinishUnload, false, "unload shouldn't be finished");
finishUnload = true;
await new Promise(resolve => setTimeout(resolve, 0));
is(didFinishUnload, true, "unload should be finished");
info("waiting for navigation to complete");
await messagePromise2;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.