зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1682676 - Part 3: Test infobars inside of the chrome r=ewright
Depends on D104741 Differential Revision: https://phabricator.services.mozilla.com/D106013
This commit is contained in:
Родитель
314b24db0d
Коммит
0d0fa2062b
|
@ -94,6 +94,9 @@ with Files("test/sync/**"):
|
|||
with Files("test/tabdialogs/**"):
|
||||
BUG_COMPONENT = ("Firefox", "Tabbed Browser")
|
||||
|
||||
with Files("test/tabnotificationbox/**"):
|
||||
BUG_COMPONENT = ("Firefox", "Tabbed Browser")
|
||||
|
||||
with Files("test/tabPrompts/**"):
|
||||
BUG_COMPONENT = ("Firefox", "Tabbed Browser")
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
extends: ["plugin:mozilla/browser-test"],
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
[browser_tabnotificationbox_switch_tabs.js]
|
|
@ -0,0 +1,160 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
function assertNotificationBoxHidden(notificationBox, reason) {
|
||||
let { stack } = notificationBox;
|
||||
let name = stack.getAttribute("name");
|
||||
ok(name, `Notification box has a name ${reason}`);
|
||||
|
||||
let { selectedViewName } = stack.parentElement;
|
||||
ok(
|
||||
selectedViewName != name,
|
||||
`Box is not shown ${reason} ${selectedViewName} != ${name}`
|
||||
);
|
||||
}
|
||||
|
||||
function assertNotificationBoxShown(notificationBox, reason) {
|
||||
let { stack } = notificationBox;
|
||||
let name = stack.getAttribute("name");
|
||||
ok(name, `Notification box has a name ${reason}`);
|
||||
|
||||
let { selectedViewName } = stack.parentElement;
|
||||
is(selectedViewName, name, `Box is shown ${reason}`);
|
||||
}
|
||||
|
||||
function createNotification({ browser, label, value, priority }) {
|
||||
let notificationBox = gBrowser.getNotificationBox(browser);
|
||||
let notification = notificationBox.appendNotification(
|
||||
label,
|
||||
value,
|
||||
null,
|
||||
notificationBox[priority],
|
||||
[]
|
||||
);
|
||||
return notification;
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.proton.infobars.enabled", true]],
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function testNotificationDeckIsLazy() {
|
||||
let deck = document.getElementById("tab-notification-deck");
|
||||
ok(!deck, "There is no tab notification deck");
|
||||
await BrowserTestUtils.withNewTab("about:blank", async browser => {
|
||||
createNotification({
|
||||
browser,
|
||||
label: "First notification",
|
||||
value: "first-notification",
|
||||
priority: "PRIORITY_INFO_LOW",
|
||||
});
|
||||
|
||||
deck = document.getElementById("tab-notification-deck");
|
||||
ok(deck, "Creating a notification created the deck");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function testNotificationInBackgroundTab() {
|
||||
let firstTab = gBrowser.selectedTab;
|
||||
|
||||
// Navigating to a page will create the notification box, so go to example.com
|
||||
await BrowserTestUtils.withNewTab("https://example.com", async browser => {
|
||||
let notificationBox = gBrowser.readNotificationBox(browser);
|
||||
ok(notificationBox, "The notification box has already been created");
|
||||
|
||||
assertNotificationBoxShown(notificationBox, "initial tab creation");
|
||||
gBrowser.selectedTab = firstTab;
|
||||
assertNotificationBoxHidden(notificationBox, "initial tab creation");
|
||||
|
||||
createNotification({
|
||||
browser,
|
||||
label: "My notification body",
|
||||
value: "test-notification",
|
||||
priority: "PRIORITY_INFO_LOW",
|
||||
});
|
||||
|
||||
gBrowser.selectedTab = gBrowser.getTabForBrowser(browser);
|
||||
assertNotificationBoxShown(notificationBox, "initial tab creation");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function testNotificationInActiveTab() {
|
||||
// Open about:blank so the notification box isn't created on tab open.
|
||||
await BrowserTestUtils.withNewTab("about:blank", async browser => {
|
||||
ok(!gBrowser.readNotificationBox(browser), "No notifications for new tab");
|
||||
|
||||
createNotification({
|
||||
browser,
|
||||
label: "Notification!",
|
||||
value: "test-notification",
|
||||
priority: "PRIORITY_INFO_LOW",
|
||||
});
|
||||
let notificationBox = gBrowser.readNotificationBox(browser);
|
||||
ok(notificationBox, "Notification box was created");
|
||||
assertNotificationBoxShown(notificationBox, "after appendNotification");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function testNotificationMultipleTabs() {
|
||||
let tabOne = gBrowser.selectedTab;
|
||||
let tabTwo = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
url: "about:blank",
|
||||
});
|
||||
let tabThree = await BrowserTestUtils.openNewForegroundTab({
|
||||
gBrowser,
|
||||
url: "https://example.com",
|
||||
});
|
||||
let browserOne = tabOne.linkedBrowser;
|
||||
let browserTwo = tabTwo.linkedBrowser;
|
||||
let browserThree = tabThree.linkedBrowser;
|
||||
|
||||
is(gBrowser.selectedBrowser, browserThree, "example.com selected");
|
||||
|
||||
let notificationBoxOne = gBrowser.readNotificationBox(browserOne);
|
||||
let notificationBoxTwo = gBrowser.readNotificationBox(browserTwo);
|
||||
let notificationBoxThree = gBrowser.readNotificationBox(browserThree);
|
||||
|
||||
ok(!notificationBoxOne, "no initial tab box");
|
||||
ok(!notificationBoxTwo, "no about:blank box");
|
||||
ok(notificationBoxThree, "example.com has a notification box");
|
||||
|
||||
// Verify the correct box is shown after creating tabs.
|
||||
assertNotificationBoxShown(notificationBoxThree, "after open");
|
||||
|
||||
createNotification({
|
||||
browser: browserTwo,
|
||||
label: "Test blank",
|
||||
value: "blank",
|
||||
priority: "PRIORITY_INFO_LOW",
|
||||
});
|
||||
notificationBoxTwo = gBrowser.readNotificationBox(browserTwo);
|
||||
ok(notificationBoxTwo, "Notification box was created");
|
||||
|
||||
// Verify the selected browser's notification box is still shown.
|
||||
assertNotificationBoxHidden(notificationBoxTwo, "hidden create");
|
||||
assertNotificationBoxShown(notificationBoxThree, "other create");
|
||||
|
||||
createNotification({
|
||||
browser: browserThree,
|
||||
label: "Test active tab",
|
||||
value: "active",
|
||||
priority: "PRIORITY_CRITICAL_LOW",
|
||||
});
|
||||
// Verify the selected browser's notification box is still shown.
|
||||
assertNotificationBoxHidden(notificationBoxTwo, "active create");
|
||||
assertNotificationBoxShown(notificationBoxThree, "active create");
|
||||
|
||||
gBrowser.selectedTab = tabTwo;
|
||||
|
||||
// Verify the notification box for the tab that has one gets shown.
|
||||
assertNotificationBoxShown(notificationBoxTwo, "tab switch");
|
||||
assertNotificationBoxHidden(notificationBoxThree, "tab switch");
|
||||
|
||||
BrowserTestUtils.removeTab(tabTwo);
|
||||
BrowserTestUtils.removeTab(tabThree);
|
||||
});
|
|
@ -56,6 +56,7 @@ BROWSER_CHROME_MANIFESTS += [
|
|||
"content/test/tabcrashed/browser.ini",
|
||||
"content/test/tabdialogs/browser.ini",
|
||||
"content/test/tabMediaIndicator/browser.ini",
|
||||
"content/test/tabnotificationbox/browser.ini",
|
||||
"content/test/tabPrompts/browser.ini",
|
||||
"content/test/tabs/browser.ini",
|
||||
"content/test/touch/browser.ini",
|
||||
|
|
Загрузка…
Ссылка в новой задаче