async function doTests(usePrivate, container) {
let alwaysNewWindow =
SpecialPowers.getIntPref(OPEN_NEWWINDOW_PREF) == OPEN_NEWWINDOW;
let window = await BrowserTestUtils.openNewBrowserWindow({ private: usePrivate,
});
let tabOpenOptions = {}; if (container) {
tabOpenOptions.userContextId = 1;
}
for (let test of TESTS) { const testid = `${test.id} (private=${usePrivate}, container=${container}, alwaysNewWindow=${alwaysNewWindow})`;
let originalTab = BrowserTestUtils.addTab(
window.gBrowser,
TEST_URL,
tabOpenOptions
);
await BrowserTestUtils.browserLoaded(originalTab.linkedBrowser);
await BrowserTestUtils.switchTab(window.gBrowser, originalTab);
let waitFor; if (test.newWindow || alwaysNewWindow) {
waitFor = BrowserTestUtils.waitForNewWindow({ url: TARGET_URL }); // Confirm that this window has private browsing set if we're doing a private browsing test
} else {
waitFor = BrowserTestUtils.waitForNewTab(
window.gBrowser,
TARGET_URL, true
);
}
let tab; if (test.newWindow || alwaysNewWindow) {
let window = await waitFor;
is(
PrivateBrowsingUtils.isWindowPrivate(window),
usePrivate, "Private status should match for " + testid
);
tab = window.gBrowser.selectedTab;
} else {
tab = await waitFor;
}
// Check that the name matches.
await SpecialPowers.spawn(
tab.linkedBrowser,
[test, container, testid],
async (test, container, testid) => { Assert.equal(
content.document.nodePrincipal.originAttributes.userContextId,
container ? 1 : 0,
`User context ID should match for ${testid}`
);
Assert.equal(
content.window.name,
test.name,
`Name should match for ${testid}`
); if (test.opener) { Assert.ok(
content.window.opener,
`Opener should have been set for ${testid}`
);
} else { Assert.ok(
!content.window.opener,
`Opener should not have been set for ${testid}`
);
}
}
);
async function doAllTests() { // Non-private window
await doTests(false, false);
// Private window
await doTests(true, false);
// Non-private window with container
await doTests(false, true);
}
// This test takes a really long time, especially in debug builds, as it is // constant starting and stopping processes, and opens a new window ~144 times.
requestLongerTimeout(30);
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 und die Messung sind noch experimentell.