fune/toolkit/components/windowwatcher/test/browser_non_popup_from_popup.js
Tooru Fujisawa 51880be4b3 Bug 1507375 - Restrict the controllability of UI parts visibility with features parameter of window.open. r=smaug
Make the features parameter of window.open just a condition for whether to open
a popup or a new tab.
Also remove dom.disable_window_open_feature.* prefs.

Differential Revision: https://phabricator.services.mozilla.com/D65926

--HG--
extra : moz-landing-system : lando
2020-03-19 09:13:12 +00:00

53 lines
1.6 KiB
JavaScript

"use strict";
// Opening non-popup from a popup should open a new tab in the most recent
// non-popup window.
add_task(async function test_non_popup_from_popup() {
const BLANK_PAGE = "data:text/html,";
// A page opened in a new tab.
const OPEN_PAGE = "data:text/plain,hello";
// A page opened in a new popup.
// This opens a new non-popup page with OPEN_PAGE,
// tha should be opened in a new tab in most recent window.
const NON_POPUP_OPENER = btoa(
`data:text/html,<script>window.open('${OPEN_PAGE}', '', '')</script>`
);
// A page opened in a new tab.
// This opens a popup with NON_POPUP_OPENER.
const POPUP_OPENER = `data:text/html,<script>window.open(atob("${NON_POPUP_OPENER}"), "", "width=500");</script>`;
await SpecialPowers.pushPrefEnv({
set: [["browser.link.open_newwindow", 3]],
});
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: BLANK_PAGE,
},
async function(browser) {
// Wait for a popup opened by POPUP_OPENER.
const newPopupPromise = BrowserTestUtils.waitForNewWindow();
// Wait for a new tab opened by NON_POPUP_OPENER.
const newTabPromise = BrowserTestUtils.waitForNewTab(gBrowser, OPEN_PAGE);
// Open a new tab that opens a popup with NON_POPUP_OPENER.
await BrowserTestUtils.loadURI(gBrowser, POPUP_OPENER);
let win = await newPopupPromise;
Assert.ok(true, "popup is opened");
let tab = await newTabPromise;
Assert.ok(true, "new tab is opened in the recent window");
BrowserTestUtils.removeTab(tab);
await BrowserTestUtils.closeWindow(win);
}
);
await SpecialPowers.popPrefEnv();
});