Bug 1745208 - [utilityOverlay] Add new tests for openWebLinkIn r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D134184
This commit is contained in:
Julien Wajsberg 2022-01-26 17:26:19 +00:00
parent e9435cc2da
commit bdb6783a8a
5 changed files with 66 additions and 0 deletions

View File

@ -106,6 +106,9 @@ with Files("test/tabs/**"):
with Files("test/touch/**"):
BUG_COMPONENT = ("Firefox", "General")
with Files("test/utilityOverlay/**"):
BUG_COMPONENT = ("Firefox", "Tabbed Browser")
with Files("test/protectionsUI/**"):
BUG_COMPONENT = ("Firefox", "Protections UI")

View File

@ -0,0 +1,5 @@
"use strict";
module.exports = {
extends: ["plugin:mozilla/browser-test"],
};

View File

@ -0,0 +1,2 @@
[DEFAULT]
[browser_openWebLinkIn.js]

View File

@ -0,0 +1,55 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const EXAMPLE_URL = "https://example.org/";
add_task(async function test_open_tab() {
const waitForTabPromise = BrowserTestUtils.waitForNewTab(
gBrowser,
EXAMPLE_URL
);
openWebLinkIn(EXAMPLE_URL, "tab");
const tab = await waitForTabPromise;
BrowserTestUtils.removeTab(tab);
});
add_task(async function test_open_window() {
const waitForWindowPromise = BrowserTestUtils.waitForNewWindow();
openWebLinkIn(EXAMPLE_URL, "window");
const win = await waitForWindowPromise;
await BrowserTestUtils.closeWindow(win);
});
add_task(async function test_open_private_window() {
const waitForWindowPromise = BrowserTestUtils.waitForNewWindow();
openWebLinkIn(EXAMPLE_URL, "window", {
private: true,
});
const win = await waitForWindowPromise;
ok(
PrivateBrowsingUtils.isBrowserPrivate(win),
"The new window is a private window."
);
await BrowserTestUtils.closeWindow(win);
});
add_task(async function test_open_private_tab_from_private_window() {
const privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
const waitForTabPromise = BrowserTestUtils.waitForNewTab(
privateWindow.gBrowser,
EXAMPLE_URL
);
privateWindow.openWebLinkIn(EXAMPLE_URL, "tab");
const tab = await waitForTabPromise;
ok(
PrivateBrowsingUtils.isBrowserPrivate(tab),
"The new tab was opened in a private browser."
);
await BrowserTestUtils.closeWindow(privateWindow);
});

View File

@ -61,6 +61,7 @@ BROWSER_CHROME_MANIFESTS += [
"content/test/tabPrompts/browser.ini",
"content/test/tabs/browser.ini",
"content/test/touch/browser.ini",
"content/test/utilityOverlay/browser.ini",
"content/test/webextensions/browser.ini",
"content/test/webrtc/browser.ini",
"content/test/webrtc/gracePeriod/browser.ini",