Open
Bug 1747085
Opened 4 years ago
BrowserTestUtils should have a utility to conceal the main window
Categories
(Testing :: General, enhancement)
Tracking
(Not tracked)
NEW
People
(Reporter: julienw, Unassigned)
Details
In some tests we may need to conceal the main window to simulate specific scenarios, eg only private windows being opened.
This could look like this:
function concealMainWindow() {
info("Concealing main window.");
let oldWinType = document.documentElement.getAttribute("windowtype");
// Check if we've already done this to allow calling multiple times:
if (oldWinType != "navigator:testrunner") {
// Make the main test window not count as a browser window any longer
document.documentElement.setAttribute("windowtype", "navigator:testrunner");
BrowserWindowTracker.untrackForTestsOnly(window);
registerCleanupFunction(() => {
info("Unconcealing the main window in the cleanup phase.");
BrowserWindowTracker.track(window);
document.documentElement.setAttribute("windowtype", oldWinType);
});
}
}
And then we could remove existing code in tests such as the one in browser/base/content/test/utilityOverlay/browser_openWebLinkIn.js (not landed yet) or https://searchfox.org/mozilla-central/rev/b605f01915c5704a55e9f485101b7be7d20a55df/browser/base/content/test/popups/browser_popup_close_main_window.js#6
You need to log in
before you can comment on or make changes to this bug.
Description
•