Backed out changeset 36b76c196497 (bug 1691499) for bc failures on browser_decoderDoctor.js. CLOSED TREE

This commit is contained in:
Cosmin Sabou
2021-02-25 21:47:25 +02:00
parent 00b825ed71
commit 97da8c128d
16 changed files with 121 additions and 168 deletions

View File

@@ -180,7 +180,9 @@ class DecoderDoctorParent extends JSWindowActorParent {
if (sumo) { if (sumo) {
buttons.push({ buttons.push({
label: gNavigatorBundle.GetStringFromName("decoder.noCodecs.button"), label: gNavigatorBundle.GetStringFromName("decoder.noCodecs.button"),
supportPage: sumo, accessKey: gNavigatorBundle.GetStringFromName(
"decoder.noCodecs.accesskey"
),
callback() { callback() {
let clickedInPref = Services.prefs.getBoolPref( let clickedInPref = Services.prefs.getBoolPref(
buttonClickedPref, buttonClickedPref,
@@ -189,6 +191,11 @@ class DecoderDoctorParent extends JSWindowActorParent {
if (!clickedInPref) { if (!clickedInPref) {
Services.prefs.setBoolPref(buttonClickedPref, true); Services.prefs.setBoolPref(buttonClickedPref, true);
} }
let baseURL = Services.urlFormatter.formatURLPref(
"app.support.baseURL"
);
window.openTrustedLinkIn(baseURL + sumo, "tab");
}, },
}); });
} }

View File

@@ -12,6 +12,12 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm" "resource://gre/modules/XPCOMUtils.jsm"
); );
ChromeUtils.defineModuleGetter(
this,
"BrowserUIUtils",
"resource:///modules/BrowserUIUtils.jsm"
);
XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() { XPCOMUtils.defineLazyGetter(this, "gBrandBundle", function() {
return Services.strings.createBundle( return Services.strings.createBundle(
"chrome://branding/locale/brand.properties" "chrome://branding/locale/brand.properties"
@@ -55,6 +61,21 @@ class EncryptedMediaParent extends JSWindowActorParent {
return true; return true;
} }
getEMEDisabledFragment(aBrowser) {
let mainMessage = gNavigatorBundle.GetStringFromName(
"emeNotifications.drmContentDisabled.message"
);
let text = gNavigatorBundle.GetStringFromName(
"emeNotifications.drmContentDisabled.learnMoreLabel"
);
let document = aBrowser.ownerDocument;
let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
let link = document.createXULElement("label", { is: "text-link" });
link.setAttribute("href", baseURL + "drm-content");
link.textContent = text;
return BrowserUIUtils.getLocalizedFragment(document, mainMessage, link);
}
getMessageWithBrandName(aNotificationId) { getMessageWithBrandName(aNotificationId) {
let msgId = "emeNotifications." + aNotificationId + ".message"; let msgId = "emeNotifications." + aNotificationId + ".message";
return gNavigatorBundle.formatStringFromName(msgId, [ return gNavigatorBundle.formatStringFromName(msgId, [
@@ -96,7 +117,6 @@ class EncryptedMediaParent extends JSWindowActorParent {
let notificationId; let notificationId;
let buttonCallback; let buttonCallback;
let supportPage;
// Notification message can be either a string or a DOM fragment. // Notification message can be either a string or a DOM fragment.
let notificationMessage; let notificationMessage;
switch (status) { switch (status) {
@@ -115,10 +135,7 @@ class EncryptedMediaParent extends JSWindowActorParent {
buttonCallback = () => { buttonCallback = () => {
this.ensureEMEEnabled(browser, keySystem); this.ensureEMEEnabled(browser, keySystem);
}; };
notificationMessage = gNavigatorBundle.GetStringFromName( notificationMessage = this.getEMEDisabledFragment(browser);
"emeNotifications.drmContentDisabled.message2"
);
supportPage = "drm-content";
break; break;
case "cdm-not-installed": case "cdm-not-installed":
@@ -150,9 +167,6 @@ class EncryptedMediaParent extends JSWindowActorParent {
} }
let buttons = []; let buttons = [];
if (supportPage) {
buttons.push({ supportPage });
}
if (buttonCallback) { if (buttonCallback) {
let msgPrefix = "emeNotifications." + notificationId + "."; let msgPrefix = "emeNotifications." + notificationId + ".";
let btnLabelId = msgPrefix + "button.label"; let btnLabelId = msgPrefix + "button.label";

View File

@@ -968,8 +968,18 @@ const gStoragePressureObserver = {
"browser.storageManager.pressureNotification.usageThresholdGB" "browser.storageManager.pressureNotification.usageThresholdGB"
); );
let msg = ""; let msg = "";
let buttons = [{ supportPage: "storage-permissions" }]; let buttons = [];
let usage = subject.QueryInterface(Ci.nsISupportsPRUint64).data; let usage = subject.QueryInterface(Ci.nsISupportsPRUint64).data;
buttons.push({
"l10n-id": "space-alert-learn-more-button",
callback(notificationBar, button) {
let learnMoreURL =
Services.urlFormatter.formatURLPref("app.support.baseURL") +
"storage-permissions";
// This is a content URL, loaded from trusted UX.
openTrustedLinkIn(learnMoreURL, "tab");
},
});
if (usage < USAGE_THRESHOLD_BYTES) { if (usage < USAGE_THRESHOLD_BYTES) {
// The firefox-used space < 5GB, then warn user to free some disk space. // The firefox-used space < 5GB, then warn user to free some disk space.
// This is because this usage is small and not the main cause for space issue. // This is because this usage is small and not the main cause for space issue.

View File

@@ -115,7 +115,7 @@ add_task(async function() {
"Should display storage pressure notification" "Should display storage pressure notification"
); );
let prefBtn = notification.getElementsByTagName("button")[0]; let prefBtn = notification.getElementsByTagName("button")[1];
let aboutPrefPromise = openAboutPrefPromise(); let aboutPrefPromise = openAboutPrefPromise();
prefBtn.doCommand(); prefBtn.doCommand();
await aboutPrefPromise; await aboutPrefPromise;

View File

@@ -3053,9 +3053,29 @@ BrowserGlue.prototype = {
var text = placesBundle.formatStringFromName("lockPrompt.text", [ var text = placesBundle.formatStringFromName("lockPrompt.text", [
applicationName, applicationName,
]); ]);
var buttonText = placesBundle.GetStringFromName(
"lockPromptInfoButton.label"
);
var accessKey = placesBundle.GetStringFromName(
"lockPromptInfoButton.accessKey"
);
var helpTopic = "places-locked";
var url = Services.urlFormatter.formatURLPref("app.support.baseURL");
url += helpTopic;
var win = BrowserWindowTracker.getTopWindow(); var win = BrowserWindowTracker.getTopWindow();
var buttons = [{ supportPage: "places-locked" }];
var buttons = [
{
label: buttonText,
accessKey,
popup: null,
callback(aNotificationBar, aButton) {
win.openTrustedLinkIn(url, "tab");
},
},
];
var notifyBox = win.gBrowser.getNotificationBox(); var notifyBox = win.gBrowser.getNotificationBox();
var notification = notifyBox.appendNotification( var notification = notifyBox.appendNotification(
@@ -4007,12 +4027,15 @@ BrowserGlue.prototype = {
accessKey: win.gNavigatorBundle.getString( accessKey: win.gNavigatorBundle.getString(
"flashHang.helpButton.accesskey" "flashHang.helpButton.accesskey"
), ),
link: callback() {
"https://support.mozilla.org/kb/flash-protected-mode-autodisabled", win.openTrustedLinkIn(
"https://support.mozilla.org/kb/flash-protected-mode-autodisabled",
"tab"
);
},
}, },
]; ];
// XXXndeakin is this notification still relevant?
win.gNotificationBox.appendNotification( win.gNotificationBox.appendNotification(
message, message,
"flash-hang", "flash-hang",

View File

@@ -538,8 +538,9 @@ pointerlock-warning-no-domain = This document has control of your pointer. Press
## Subframe crash notification ## Subframe crash notification
crashed-subframe-message = <strong>Part of this page crashed.</strong> To let { -brand-product-name } know about this issue and get it fixed faster, please submit a report. crashed-subframe-message = <strong>Part of this page crashed.</strong> To let { -brand-product-name } know about this issue and get it fixed faster, please submit a report.
crashed-subframe-learnmore-link = crashed-subframe-learnmore =
.value = Learn More .label = Learn More
.accesskey = L
crashed-subframe-submit = crashed-subframe-submit =
.label = Submit report .label = Submit report
.accesskey = S .accesskey = S

View File

@@ -1330,6 +1330,10 @@ certs-devices =
.label = Security Devices… .label = Security Devices…
.accesskey = D .accesskey = D
space-alert-learn-more-button =
.label = Learn More
.accesskey = L
space-alert-over-5gb-pref-button = space-alert-over-5gb-pref-button =
.label = .label =
{ PLATFORM() -> { PLATFORM() ->

View File

@@ -861,9 +861,11 @@ emeNotifications.drmContentPlaying.button.label = Configure…
emeNotifications.drmContentPlaying.button.accesskey = C emeNotifications.drmContentPlaying.button.accesskey = C
# LOCALIZATION NOTE(emeNotifications.drmContentDisabled.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. %S will be the 'learn more' link # LOCALIZATION NOTE(emeNotifications.drmContentDisabled.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. %S will be the 'learn more' link
emeNotifications.drmContentDisabled.message2 = You must enable DRM to play some audio or video on this page. emeNotifications.drmContentDisabled.message = You must enable DRM to play some audio or video on this page. %S
emeNotifications.drmContentDisabled.button.label = Enable DRM emeNotifications.drmContentDisabled.button.label = Enable DRM
emeNotifications.drmContentDisabled.button.accesskey = E emeNotifications.drmContentDisabled.button.accesskey = E
# LOCALIZATION NOTE(emeNotifications.drmContentDisabled.learnMoreLabel): NB: inserted via innerHTML, so please don't use <, > or & in this string.
emeNotifications.drmContentDisabled.learnMoreLabel = Learn More
# LOCALIZATION NOTE(emeNotifications.drmContentCDMInstalling.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. %S is brandShortName # LOCALIZATION NOTE(emeNotifications.drmContentCDMInstalling.message): NB: inserted via innerHTML, so please don't use <, > or & in this string. %S is brandShortName
emeNotifications.drmContentCDMInstalling.message = %S is installing components needed to play the audio or video on this page. Please try again later. emeNotifications.drmContentCDMInstalling.message = %S is installing components needed to play the audio or video on this page. Please try again later.

View File

@@ -54,6 +54,8 @@ detailsPane.itemsCountLabel=One item;#1 items
# %S will be replaced with the application name. # %S will be replaced with the application name.
lockPrompt.title=Browser Startup Error lockPrompt.title=Browser Startup Error
lockPrompt.text=The bookmarks and history system will not be functional because one of %Ss files is in use by another application. Some security software can cause this problem. lockPrompt.text=The bookmarks and history system will not be functional because one of %Ss files is in use by another application. Some security software can cause this problem.
lockPromptInfoButton.label=Learn More
lockPromptInfoButton.accessKey=L
# LOCALIZATION NOTE (cmd.deleteSinglePage.accesskey, # LOCALIZATION NOTE (cmd.deleteSinglePage.accesskey,
# cmd.deleteMultiplePages.accesskey): these accesskeys can use the same # cmd.deleteMultiplePages.accesskey): these accesskeys can use the same

View File

@@ -409,9 +409,11 @@ var TabCrashHandler = {
let buttons = [ let buttons = [
{ {
"l10n-id": "crashed-subframe-learnmore-link", "l10n-id": "crashed-subframe-learnmore",
popup: null, popup: null,
link: SUBFRAMECRASH_LEARNMORE_URI, callback: async () => {
doc.defaultView.openTrustedLinkIn(SUBFRAMECRASH_LEARNMORE_URI, "tab");
},
}, },
{ {
"l10n-id": "crashed-subframe-submit", "l10n-id": "crashed-subframe-submit",

View File

@@ -522,11 +522,6 @@ var ProcessHangMonitor = {
let bundle = win.gNavigatorBundle; let bundle = win.gNavigatorBundle;
let buttons = [ let buttons = [
{
label: bundle.getString("processHang.add-on.learn-more.text"),
link:
"https://support.mozilla.org/kb/warning-unresponsive-script#w_other-causes",
},
{ {
label: bundle.getString("processHang.button_stop.label"), label: bundle.getString("processHang.button_stop.label"),
accessKey: bundle.getString("processHang.button_stop.accessKey"), accessKey: bundle.getString("processHang.button_stop.accessKey"),
@@ -554,11 +549,27 @@ var ProcessHangMonitor = {
let addonName = aps.getExtensionName(report.addonId); let addonName = aps.getExtensionName(report.addonId);
message = bundle.getFormattedString("processHang.add-on.label", [ let label = bundle.getFormattedString("processHang.add-on.label", [
addonName, addonName,
brandBundle.getString("brandShortName"), brandBundle.getString("brandShortName"),
]); ]);
let linkText = bundle.getString("processHang.add-on.learn-more.text");
let linkURL =
"https://support.mozilla.org/kb/warning-unresponsive-script#w_other-causes";
let link = doc.createXULElement("label", { is: "text-link" });
link.setAttribute("role", "link");
link.setAttribute(
"onclick",
`openTrustedLinkIn(${JSON.stringify(linkURL)}, "tab")`
);
link.setAttribute("value", linkText);
message = doc.createDocumentFragment();
message.appendChild(doc.createTextNode(label + " "));
message.appendChild(link);
buttons.unshift({ buttons.unshift({
label: bundle.getString("processHang.button_stop_sandbox.label"), label: bundle.getString("processHang.button_stop_sandbox.label"),
accessKey: bundle.getString( accessKey: bundle.getString(

View File

@@ -160,14 +160,8 @@ async function testFrameCrash(numTabs) {
let buttons = notification.querySelectorAll(".notification-button"); let buttons = notification.querySelectorAll(".notification-button");
is( is(
buttons.length, buttons.length,
1, 2,
"Notification " + count + " should have only one button." "Notification " + count + " should have only two buttons."
);
let links = notification.querySelectorAll(".text-link");
is(
links.length,
1,
"Notification " + count + " should have only one link."
); );
} }

View File

@@ -29,33 +29,8 @@ var testtag_notificationbox_buttons = [
} }
]; ];
var testtag_notificationbox_links = [ function testtag_notificationbox_buttonpressed(event)
{
label: "Link 1",
callback: testtag_notificationbox_buttonpressed,
link: "about:mozilla"
},
{
label: "Button 2",
accesskey: "u",
callback: testtag_notificationbox_buttonpressed,
}
];
var testtag_notificationbox_supportpage = [
{
supportPage: "test1",
},
{
label: "This is an existing label",
supportPage: "test2",
}
];
function testtag_notificationbox_buttonpressed(notification, button)
{ {
SimpleTest.is(button.localName, "button");
return false;
} }
function testtag_notificationbox(nb) function testtag_notificationbox(nb)
@@ -303,54 +278,6 @@ var tests =
SimpleTest.is(nb.removeAllNotifications(false), undefined, "removeAllNotifications"); SimpleTest.is(nb.removeAllNotifications(false), undefined, "removeAllNotifications");
} }
}, },
{
test(nb, ntf) {
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_LOW,
testtag_notificationbox_links,
notification_eventCallback);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append link notification with callback");
return ntf;
},
result(nb, ntf) {
testtag_notificationbox_State(nb, "append link with callback", ntf, 1);
let button = ntf.messageDetails.lastElementChild;
SimpleTest.is(button.localName, "button", "button is a button");
SimpleTest.ok(!button.href, "button href is not set");
let link = ntf.messageText.lastElementChild;
SimpleTest.is(link.localName, "label", "link is a label");
SimpleTest.is(link.href, "about:mozilla", "link href is correct");
SimpleTest.is(nb.removeAllNotifications(false), undefined, "removeAllNotifications");
}
},
{
test(nb, ntf) {
ntf = nb.appendNotification("Notification", "note", "happy.png",
nb.PRIORITY_INFO_LOW,
testtag_notificationbox_supportpage,
notification_eventCallback);
SimpleTest.is(ntf && ntf.localName == "notification", true, "append support page notification");
return ntf;
},
result(nb, ntf) {
testtag_notificationbox_State(nb, "append link with callback", ntf, 1);
let link = ntf.messageText.lastElementChild.previousSibling;
SimpleTest.is(link.localName, "label", "link 1 is a label");
SimpleTest.ok(link.value != "", "link 1 label is set");
SimpleTest.ok(link.href.endsWith("/test1"), "link 1 href is set");
link = ntf.messageText.lastElementChild;
SimpleTest.is(link.localName, "label", "link 2 is a label");
SimpleTest.is(link.value, "This is an existing label", "link 2 label is set");
SimpleTest.ok(link.href.endsWith("/test2"), "link 2 href is set");
SimpleTest.is(nb.removeAllNotifications(false), undefined, "removeAllNotifications");
}
},
{ {
test(nb, unused) { test(nb, unused) {
// add a number of notifications and check that they are added in order // add a number of notifications and check that they are added in order
@@ -455,7 +382,7 @@ var appendPriorityTests = [
runTimedTests(appendPriorityTests, -1, nb, ++priority); runTimedTests(appendPriorityTests, -1, nb, ++priority);
} }
} }
}, }
]; ];
function testtag_notificationbox_State(nb, testid, expecteditem, expectedcount) function testtag_notificationbox_State(nb, testid, expecteditem, expectedcount)

View File

@@ -107,13 +107,6 @@
* 2. This button object definition. * 2. This button object definition.
* 3. The <button> element. * 3. The <button> element.
* 4. The "command" event. * 4. The "command" event.
* If the callback returns false, the notification is closed.
* link:
* A url to open when the button is clicked. The button is
* rendered like a link. The callback is called as well.
* supportPage:
* Used for a support page link. If no other properties are specified,
* defaults to a link with a 'Learn more' label.
* popup: * popup:
* If specified, the button will open the popup element with this * If specified, the button will open the popup element with this
* ID, anchored to the button. This is alternative to "callback". * ID, anchored to the button. This is alternative to "callback".
@@ -160,8 +153,6 @@
insertPos = notifications[n]; insertPos = notifications[n];
} }
MozXULElement.insertFTLIfNeeded("toolkit/global/notification.ftl");
// Create the Custom Element and connect it to the document immediately. // Create the Custom Element and connect it to the document immediately.
var newitem = document.createXULElement( var newitem = document.createXULElement(
"notification", "notification",
@@ -191,52 +182,27 @@
if (aButtons) { if (aButtons) {
for (var b = 0; b < aButtons.length; b++) { for (var b = 0; b < aButtons.length; b++) {
let button = aButtons[b]; var button = aButtons[b];
let buttonElem; var buttonElem = document.createXULElement(
"button",
button.is ? { is: button.is } : {}
);
let link = button.link; if (button["l10n-id"]) {
let localeId = button["l10n-id"]; buttonElem.setAttribute("data-l10n-id", button["l10n-id"]);
if (!link && button.supportPage) {
link =
Services.urlFormatter.formatURLPref("app.support.baseURL") +
button.supportPage;
if (!button.label && !localeId) {
localeId = "notification-learnmore-default-label";
}
}
if (link) {
buttonElem = document.createXULElement("label", {
is: "text-link",
});
buttonElem.setAttribute("href", link);
buttonElem.classList.add("notification-link");
} else { } else {
buttonElem = document.createXULElement( buttonElem.setAttribute("label", button.label);
"button",
button.is ? { is: button.is } : {}
);
buttonElem.classList.add("notification-button");
if (button.primary) {
buttonElem.classList.add("primary");
}
}
if (localeId) {
buttonElem.setAttribute("data-l10n-id", localeId);
} else {
buttonElem.setAttribute(link ? "value" : "label", button.label);
if (typeof button.accessKey == "string") { if (typeof button.accessKey == "string") {
buttonElem.setAttribute("accesskey", button.accessKey); buttonElem.setAttribute("accesskey", button.accessKey);
} }
} }
if (link) { buttonElem.classList.add("notification-button");
newitem.messageText.appendChild(buttonElem); if (button.primary) {
} else { buttonElem.classList.add("primary");
newitem.messageDetails.appendChild(buttonElem);
} }
newitem.messageDetails.appendChild(buttonElem);
buttonElem.buttonInfo = button; buttonElem.buttonInfo = button;
} }
} }

View File

@@ -1,6 +0,0 @@
# 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/.
notification-learnmore-default-label =
.value = Learn more

View File

@@ -84,13 +84,9 @@ notification[type="critical"] > .close-icon:hover:active {
} }
.messageText > .text-link { .messageText > .text-link {
text-decoration: underline;
margin-block: 0;
}
.messageText > .text-link:not(.notification-link) {
color: inherit !important; color: inherit !important;
margin-inline: 0; text-decoration: underline;
margin: 0;
} }
.messageImage { .messageImage {