commit b9474292c05a8f33da837ceae91f1ede7768d2a3
parent 8f39ccbc3c48ef0f2cadd9ec3320631c018cafb2
Author: Rob Wu <rob@robwu.nl>
Date: Mon, 20 Oct 2025 14:12:25 +0000
Bug 1994074 - Add Learn more link to safe mode message bars r=rpl
This also corrects the l10n ID for the "learn more" link of message bars
in the extensions panel. Before this patch, the l10n ID of quarantined
domains was also applied to unrelated message bars. Did was not obvious
because the rendered text in either case is "Learn more". However, due
to the use of this l10n ID, a misleading aria-label was set.
Differential Revision: https://phabricator.services.mozilla.com/D268461
Diffstat:
5 files changed, 45 insertions(+), 13 deletions(-)
diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js
@@ -2488,6 +2488,7 @@ var gUnifiedExtensions = {
if (Services.appinfo.inSafeMode) {
this._messageBarSafemode ??= this._makeMessageBar({
messageBarFluentId: "unified-extensions-notice-safe-mode",
+ supportPage: "diagnose-firefox-issues-using-troubleshoot-mode",
type: "info",
});
container.prepend(this._messageBarSafemode);
@@ -2508,6 +2509,8 @@ var gUnifiedExtensions = {
messageBarFluentId:
"unified-extensions-mb-quarantined-domain-message-3",
supportPage: "quarantined-domains",
+ supportPageFluentId:
+ "unified-extensions-mb-quarantined-domain-learn-more",
dismissible: false,
});
this._messageBarQuarantinedDomain
@@ -3140,6 +3143,7 @@ var gUnifiedExtensions = {
messageBarFluentId,
messageBarFluentArgs,
supportPage = null,
+ supportPageFluentId,
linkToAboutAddons = false,
type = "warning",
}) {
@@ -3181,11 +3185,9 @@ var gUnifiedExtensions = {
is: "moz-support-link",
});
supportUrl.setAttribute("support-page", supportPage);
- document.l10n.setAttributes(
- supportUrl,
- "unified-extensions-mb-quarantined-domain-learn-more"
- );
- supportUrl.setAttribute("data-l10n-attrs", "aria-label");
+ if (supportPageFluentId) {
+ document.l10n.setAttributes(supportUrl, supportPageFluentId);
+ }
supportUrl.setAttribute("slot", "support-link");
messageBar.append(supportUrl);
diff --git a/browser/components/extensions/test/browser/browser_unified_extensions_empty_panel.js b/browser/components/extensions/test/browser/browser_unified_extensions_empty_panel.js
@@ -659,6 +659,13 @@ add_task(async function test_safe_mode_notice() {
is(bar.getAttribute("type"), "info", "Bar is informational notice");
ok(!bar.hasAttribute("dismissable"), "Bar is not dismissable");
+ const supportLink = bar.querySelector("a");
+ is(
+ supportLink.getAttribute("support-page"),
+ "diagnose-firefox-issues-using-troubleshoot-mode",
+ "expected the correct support page ID"
+ );
+
// We don't exactly care which empty state is shown, as the notice is
// independent of the empty state. We just verify as a sanity check that the
// panel is indeed empty, which is most realistic when users enter safe mode.
diff --git a/browser/components/extensions/test/browser/browser_unified_extensions_messages.js b/browser/components/extensions/test/browser/browser_unified_extensions_messages.js
@@ -610,7 +610,7 @@ add_task(async function test_quarantined_and_blocklist_message() {
await openExtensionsPanel();
let messages = getMessageBars();
Assert.equal(messages.length, 1, "expected a message");
- verifyQuarantinedDomainsMessageBar(messages[0]);
+ await verifyQuarantinedDomainsMessageBar(messages[0]);
await closeExtensionsPanel();
let promiseBlocklistAttentionUpdated = AddonTestUtils.promiseManagerEvent(
@@ -638,7 +638,7 @@ add_task(async function test_quarantined_and_blocklist_message() {
},
},
});
- verifyQuarantinedDomainsMessageBar(messages[1]);
+ await verifyQuarantinedDomainsMessageBar(messages[1]);
await closeExtensionsPanel();
cleanupBlocklist();
}
diff --git a/toolkit/mozapps/extensions/content/aboutaddons.js b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -789,7 +789,9 @@ class GlobalWarnings extends MessageBarStackElement {
refresh() {
if (this.inSafeMode) {
- this.setWarning("safe-mode");
+ this.setWarning("safe-mode", {
+ supportPage: "diagnose-firefox-issues-using-troubleshoot-mode",
+ });
} else if (
AddonManager.checkUpdateSecurityDefault &&
!AddonManager.checkUpdateSecurity
@@ -804,7 +806,7 @@ class GlobalWarnings extends MessageBarStackElement {
}
}
- setWarning(type, opts) {
+ setWarning(type, { action, supportPage }) {
if (
this.globalWarning &&
this.globalWarning.getAttribute("warning-type") !== type
@@ -817,7 +819,13 @@ class GlobalWarnings extends MessageBarStackElement {
let { messageId, buttonId } = this.getGlobalWarningL10nIds(type);
document.l10n.setAttributes(this.globalWarning, messageId);
this.globalWarning.setAttribute("data-l10n-attrs", "message");
- if (opts && opts.action) {
+ if (supportPage) {
+ let link = document.createElement("a", { is: "moz-support-link" });
+ link.setAttribute("slot", "support-link");
+ link.setAttribute("support-page", supportPage);
+ this.globalWarning.appendChild(link);
+ }
+ if (action) {
let button = document.createElement("button");
document.l10n.setAttributes(button, buttonId);
button.setAttribute("action", type);
diff --git a/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js b/toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js
@@ -16,7 +16,7 @@ async function loadDetail(win, id) {
await loaded;
}
-function checkMessageShown(win, type, hasButton) {
+function checkMessageShown(win, type, hasButton, expectedSupportPage) {
let stack = win.document.querySelector("global-warnings");
is(stack.childElementCount, 1, "There is one message");
let messageBar = stack.firstElementChild;
@@ -38,6 +38,18 @@ function checkMessageShown(win, type, hasButton) {
is_element_visible(button, "Button is visible");
is(button.getAttribute("action"), type, "Button action is set");
}
+
+ const supportLinkEls = messageBar.supportLinkEls;
+ if (expectedSupportPage) {
+ Assert.equal(1, supportLinkEls.length, "Got Learn mode link");
+ Assert.equal(
+ expectedSupportPage,
+ supportLinkEls[0].supportPage,
+ "Learn more link points to expected destination"
+ );
+ } else {
+ Assert.equal(0, supportLinkEls.length, "No Learn mode links");
+ }
}
function checkNoMessages(win) {
@@ -166,13 +178,16 @@ add_task(async function checkSafeMode() {
globalWarnings.inSafeMode = true;
globalWarnings.refresh();
+ const safeModeSupportsPage =
+ "diagnose-firefox-issues-using-troubleshoot-mode";
+
// Check detail view.
await loadDetail(win, id);
- checkMessageShown(win, "safe-mode");
+ checkMessageShown(win, "safe-mode", false, safeModeSupportsPage);
// Check other views.
await switchView(win, "theme");
- checkMessageShown(win, "safe-mode");
+ checkMessageShown(win, "safe-mode", false, safeModeSupportsPage);
await switchView(win, "plugin");
checkNoMessages(win);