async function pollForPage() {
while (true) {
try {
// When we do our navigation, there may be an interstitial about:blank
// page if the navigation involves a process switch. That about:blank
// will exist between the new process's docshell being created and the
// actual page that's being loaded loading (which can happen async from
// the docshell creation). We want to avoid treating the initial
// about:blank as a new page.
//
// We could conceivably expose Document::IsInitialDocument() as a
// ChromeOnly thing and use it here, but let's just filter out all
// about:blank, since we don't expect any in this test. var haveNewPage = await SpecialPowers.spawn(w, [token],
currentToken => this.content.token != currentToken &&
this.content.location.href != "about:blank");
if (haveNewPage) {
++token;
assignToken(token);
break;
}
} catch (e) {
// Something went wrong; just keep waiting.
}
await delay(100);
}
}
async function windowLoaded() {
switch (phase) {
case 0:
assignToken(token);
/* 2. We have succeededfully loaded a page, now go to a faulty URL */
window.setTimeout(function() {
w.location.href = faultyURL;
}, 0);
phase = 1;
await pollForPage(w);
is(await SpecialPowers.spawn(w, [], () => this.content.location.href),
faultyURL, "Is on an error page initially");
/* 3. now, while we are on the error page, try to reload it, actually
click the "Try Again"button */
SpecialPowers.spawn(w, [], () => this.content.location.reload());
await pollForPage(w);
/* 4-finish, check we are still on the error page */
is(await SpecialPowers.spawn(w, [], () => this.content.location.href),
faultyURL, "Is on an error page");
is(gotWrongPageOnTryAgainClick, false, "Must not get www.example.com page on reload of an error page");
w.close();
SimpleTest.finish();
break;
case 1:
/* 4-check, we must not get here! */
gotWrongPageOnTryAgainClick = true;
break;
}
}
function startTest() {
/* 1. load a URL that leads to an error page */
w = window.open(workingURL);
}
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.