// Maintain a pool of background tabs with our test document loaded so // we don't have to wait for a load prior to each test step (potentially // tearing down and recreating content processes in the process). const TabPool = {
poolSize: 5,
pendingCount: 0,
readyTabs: [],
readyPromise: null,
resolveReadyPromise: null,
spawnTabs() { while (this.pendingCount + this.readyTabs.length < this.poolSize) { this.pendingCount++;
let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE);
BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => { this.readyTabs.push(tab); this.pendingCount--;
// Wait for round trip messages to any processes with event listeners to // return so we're sure that all listeners are registered and their state // flags are propagated before we continue.
await Promise.all(roundTripPromises);
async function doTest(actions, startIdx, navigate) {
let tab = await TabPool.getTab();
let browser = tab.linkedBrowser;
let frames = descendants(browser.browsingContext);
let expected = await addListeners(frames, actions, startIdx);
let awaitingPrompt = false;
let promptPromise; if (expected.expectPrompt) {
awaitingPrompt = true;
promptPromise = promiseAllowUnloadPrompt(browser, false).then(() => {
awaitingPrompt = false;
});
}
let promptCount = expected.expectPrompt ? 1 : 0;
await withTabModalPromptCount(promptCount, async () => {
await navigate(tab, frames).then(result => {
ok(
!awaitingPrompt, "Navigation should not complete while we're still expecting a prompt"
);
is(
result.eventLoopSpun,
expected.expectNestedEventLoop, "Should have nested event loop?"
);
});
for (let result of await Promise.all(expected.beforeUnloadPromises)) {
is(
result.event, "beforeunload", "Should have seen beforeunload event before unload"
);
}
await promptPromise;
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.