Bug 1702330 - Graduate infobars to main proton pref r=jaws,marionette-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D110638
This commit is contained in:
Mark Striemer 2021-04-09 15:26:24 +00:00
parent 0c5965a080
commit 71680c44e5
14 changed files with 29 additions and 60 deletions

View File

@ -125,7 +125,7 @@ add_task(async () => {
// 5. Accessibility announcements dialog (#a11y-announcement)
// 6. Tab notification deck (#tab-notification-deck) (proton only)
let baseRootChildCount = Services.prefs.getBoolPref(
"browser.proton.infobars.enabled",
"browser.proton.enabled",
false
)
? 6

View File

@ -34,8 +34,8 @@ XPCOMUtils.defineLazyPreferenceGetter(
XPCOMUtils.defineLazyPreferenceGetter(
this,
"PROTON_INFOBARS_ENABLED",
"browser.proton.infobars.enabled",
"PROTON_ENABLED",
"browser.proton.enabled",
false
);
@ -162,7 +162,7 @@ var DefaultBrowserNotification = {
let iconPixels = win.devicePixelRatio > 1 ? "64" : "32";
let iconURL = "chrome://branding/content/icon" + iconPixels + ".png";
const priority = PROTON_INFOBARS_ENABLED
const priority = PROTON_ENABLED
? win.gNotificationBox.PRIORITY_SYSTEM
: win.gNotificationBox.PRIORITY_INFO_MEDIUM;
let callback = this._onNotificationEvent.bind(this);

View File

@ -397,7 +397,7 @@ XPCOMUtils.defineLazyGetter(this, "gHighPriorityNotificationBox", () => {
return new MozElements.NotificationBox(element => {
element.classList.add("global-notificationbox");
element.setAttribute("notificationside", "top");
if (gProtonInfobarsEnabled) {
if (gProton) {
// With Proton enabled all notification boxes are at the top, built into the browser chrome.
let tabNotifications = document.getElementById("tab-notification-deck");
gNavToolbox.insertBefore(element, tabNotifications);
@ -409,7 +409,7 @@ XPCOMUtils.defineLazyGetter(this, "gHighPriorityNotificationBox", () => {
// Regular notification bars shown at the bottom of the window.
XPCOMUtils.defineLazyGetter(this, "gNotificationBox", () => {
return gProtonInfobarsEnabled
return gProton
? gHighPriorityNotificationBox
: new MozElements.NotificationBox(element => {
element.classList.add("global-notificationbox");
@ -588,14 +588,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
}
);
/* Temporary pref while the Proton infobars work stabilizes. */
XPCOMUtils.defineLazyPreferenceGetter(
this,
"gProtonInfobarsEnabled",
"browser.proton.infobars.enabled",
false
);
/* Temporary pref while the dust settles around the updated tooltip design
for tabs and bookmarks toolbar. This will eventually be removed and
browser.proton.enabled will be used instead. */

View File

@ -826,7 +826,7 @@
if (!browser._notificationBox) {
browser._notificationBox = new MozElements.NotificationBox(element => {
element.setAttribute("notificationside", "top");
if (gProtonInfobarsEnabled) {
if (gProton) {
element.setAttribute(
"name",
`tab-notification-box-${this._nextNotificationBoxId++}`
@ -1112,7 +1112,7 @@
this._appendStatusPanel();
if (gProtonInfobarsEnabled) {
if (gProton) {
this._updateVisibleNotificationBox(newBrowser);
}

View File

@ -31,7 +31,7 @@ function openAboutPrefPromise(win) {
for (let protonEnabled of [true, false]) {
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["browser.proton.infobars.enabled", protonEnabled]],
set: [["browser.proton.enabled", protonEnabled]],
});
let win = await BrowserTestUtils.openNewWindowWithFlushedXULCacheForMozSupports();
// Open a new tab to keep the window open.

View File

@ -38,7 +38,7 @@ function createNotification({ browser, label, value, priority }) {
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["browser.proton.infobars.enabled", true]],
set: [["browser.proton.enabled", true]],
});
});

View File

@ -94,14 +94,9 @@ async function test_decoder_doctor_notification(
}
ok(notification, "Got decoder-doctor-notification notification");
const protonInfobarsEnabled = Services.prefs.getBoolPref(
"browser.proton.infobars.enabled",
false
);
is(
notification.messageText.textContent,
notificationMessage +
(protonInfobarsEnabled && isLink && label ? " " : ""),
notificationMessage + (gProton && isLink && label ? " " : ""),
"notification message should match expectation"
);

View File

@ -101,7 +101,7 @@ class TestSafeBrowsingNotificationBar(WindowManagerMixin, MarionetteTestCase):
def check_get_me_out_of_here_button(self):
with self.marionette.using_context("chrome"):
if self.marionette.get_pref("browser.proton.infobars.enabled"):
if self.marionette.get_pref("browser.proton.enabled"):
notification_box = self.marionette.find_element(
By.CSS_SELECTOR, 'vbox.notificationbox-stack[slot="selected"]'
)
@ -125,7 +125,7 @@ class TestSafeBrowsingNotificationBar(WindowManagerMixin, MarionetteTestCase):
def check_x_button(self):
with self.marionette.using_context("chrome"):
if self.marionette.get_pref("browser.proton.infobars.enabled"):
if self.marionette.get_pref("browser.proton.enabled"):
notification_box = self.marionette.find_element(
By.CSS_SELECTOR, 'vbox.notificationbox-stack[slot="selected"]'
)

View File

@ -220,9 +220,7 @@ var Heartbeat = class {
this.ratingContainer.appendChild(ratingElement);
}
if (
Services.prefs.getBoolPref("browser.proton.infobars.enabled", false)
) {
if (Services.prefs.getBoolPref("browser.proton.enabled")) {
// This will append if there aren't any .text-link elements.
this.notice.buttonContainer.append(this.ratingContainer);
} else {

View File

@ -88,7 +88,7 @@ function getStars(notice, protonEnabled) {
for (let protonEnabled of [true, false]) {
add_task(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["browser.proton.infobars.enabled", protonEnabled]],
set: [["browser.proton.enabled", protonEnabled]],
});
let win = await BrowserTestUtils.openNewWindowWithFlushedXULCacheForMozSupports();
// Open a new tab to keep the window open.

View File

@ -19,8 +19,8 @@
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const PROTON_INFOBARS_ENABLED = Services.prefs.getBoolPref("browser.proton.infobars.enabled", false);
const NOTIFICATION_LOCAL_NAME = PROTON_INFOBARS_ENABLED ? "notification-message" : "notification";
const PROTON_ENABLED = Services.prefs.getBoolPref("browser.proton.enabled", false);
const NOTIFICATION_LOCAL_NAME = PROTON_ENABLED ? "notification-message" : "notification";
SimpleTest.waitForExplicitFinish();
var testtag_notificationbox_buttons = [
@ -318,7 +318,7 @@ var tests =
result(nb, ntf) {
testtag_notificationbox_State(nb, "append link with callback", ntf, 1);
let buttonContainer = PROTON_INFOBARS_ENABLED ? ntf.buttonContainer : ntf.messageDetails;
let buttonContainer = PROTON_ENABLED ? ntf.buttonContainer : ntf.messageDetails;
let button = buttonContainer.lastElementChild;
SimpleTest.is(button.localName, "button", "button is a button");
SimpleTest.ok(!button.href, "button href is not set");
@ -342,7 +342,7 @@ var tests =
result(nb, ntf) {
testtag_notificationbox_State(nb, "append link with callback", ntf, 1);
let link = PROTON_INFOBARS_ENABLED
let link = PROTON_ENABLED
? ntf.messageText.lastElementChild.previousSibling.previousSibling
: ntf.messageText.lastElementChild.previousSibling;
SimpleTest.is(link.localName, "label", "link 1 is a label");
@ -498,7 +498,7 @@ function testtag_notification_State(nb, ntf, testid, label, value, image, priori
is(ntf.getAttribute("type"), type, testid + " notification type");
if (PROTON_INFOBARS_ENABLED) {
if (PROTON_ENABLED) {
let icons = {
info: "chrome://global/skin/icons/info.svg",
warning: "chrome://global/skin/icons/warning.svg",
@ -519,7 +519,7 @@ function checkPopupTest(nb, ntf)
var evt = new Event("");
ntf.dispatchEvent(evt);
evt.target.buttonInfo = testtag_notificationbox_buttons[0];
if (PROTON_INFOBARS_ENABLED) {
if (PROTON_ENABLED) {
ntf.handleEvent(evt);
} else {
ntf._doButtonCommand(evt);

View File

@ -148,7 +148,7 @@
flex-shrink: 0;
}
@media (-moz-proton-infobars) {
@media (-moz-proton) {
@media not (prefers-contrast) {
.container.infobar {
box-shadow: 0 1px 2px rgba(58, 57, 68, 0.1);
@ -276,7 +276,7 @@ strong {
}
}
@media not (-moz-proton-infobars) {
@media not (-moz-proton) {
:host {
/* Colors used by default, and for [type=generic] message bars.*/
background-color: var(--in-content-box-info-background);

View File

@ -29,12 +29,10 @@
get stack() {
if (!this._stack) {
let stack;
stack = document.createXULElement(
this.protonInfobarsEnabled ? "vbox" : "legacy-stack"
);
stack = document.createXULElement(gProton ? "vbox" : "legacy-stack");
stack._notificationBox = this;
stack.className = "notificationbox-stack";
if (!this.protonInfobarsEnabled) {
if (!gProton) {
stack.appendChild(document.createXULElement("spacer"));
}
stack.addEventListener("transitionend", event => {
@ -171,7 +169,7 @@
// Create the Custom Element and connect it to the document immediately.
var newitem;
if (this.protonInfobarsEnabled && !aNotificationIs) {
if (gProton && !aNotificationIs) {
if (!customElements.get("notification-message")) {
// There's some weird timing stuff when this element is created at
// script load time, we don't need it until now anyway so be lazy.
@ -206,7 +204,7 @@
}
newitem.setAttribute("value", aValue);
if (aImage && !this.protonInfobarsEnabled) {
if (aImage && !gProton) {
newitem.messageImage.setAttribute("src", aImage);
}
newitem.eventCallback = aEventCallback;
@ -247,7 +245,7 @@
if (!aItem.parentNode) {
return;
}
if (this.protonInfobarsEnabled) {
if (gProton) {
this.currentNotification = aItem;
this.removeCurrentNotification(aSkipAnimation);
} else if (aItem == this.currentNotification) {
@ -362,13 +360,6 @@
}
}
}
get protonInfobarsEnabled() {
return Services.prefs.getBoolPref(
"browser.proton.infobars.enabled",
false
);
}
};
// These are defined on the instance prototype for backwards compatibility.
@ -546,13 +537,6 @@
}
}
}
get protonInfobarsEnabled() {
return Services.prefs.getBoolPref(
"browser.proton.infobars.enabled",
false
);
}
};
customElements.define("notification", MozElements.Notification);

View File

@ -191,7 +191,7 @@ notification[type="critical"] > hbox > .messageImage {
background-color: var(--notification-primary-button-background-active);
}
@media (-moz-proton-infobars) {
@media (-moz-proton) {
.notificationbox-stack {
background-color: var(--toolbar-bgcolor);
width: 100%;