commit 0bdd205fe0beca56c7cba82f458308b2a8650123 parent a6fd653fe82a756e0580c42875e495b06132aaba Author: Tim Giles <tgiles@mozilla.com> Date: Wed, 12 Nov 2025 20:52:52 +0000 Bug 1991186 - Add support link to the extension controlled moz-message-bar. r=mkennedy This change implements adding a support link to the extension controlled moz-message-bar element. By adding `supportPage` to the `controllingExtensionInfo` object when adding a config-based Setting, we will automatically render a "Learn more" support link when the correct message bar is present. Differential Revision: https://phabricator.services.mozilla.com/D271302 Diffstat:
6 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/browser/components/preferences/tests/chrome/test_setting_control_extension_controlled.html b/browser/components/preferences/tests/chrome/test_setting_control_extension_controlled.html @@ -121,6 +121,8 @@ const ADDON_NAME = "Ext Controlled"; const STORE_ID = "privacy.containers"; const TEST_FLUENT_ID = "test-fluent-id"; + const SUPPORT_PAGE = "support-test"; + const SUPPORT_URL = Services.prefs.getStringPref("app.support.baseURL"); await SpecialPowers.pushPrefEnv({ set: [[PREF_ID, false]], }); @@ -152,6 +154,7 @@ controllingExtensionInfo: { storeId: STORE_ID, l10nId: TEST_FLUENT_ID, + supportPage: SUPPORT_PAGE, }, }); @@ -217,6 +220,21 @@ "disable-extension", "The disable extension button should have the correct data-l10n-id" ); + + // Assert that moz-message-bar appears with a support link with correct attributes + let supportLink = messageBar.querySelector("a[slot='support-link']"); + ok(supportLink, "There should be a slotted support link element"); + is( + supportLink.getAttribute("support-page"), + SUPPORT_PAGE, + "The support link should have the correct value for 'support-page'" + ); + is( + supportLink.href, + `${SUPPORT_URL}${SUPPORT_PAGE}`, + "The support link should have the correct generated href value" + ); + // Unload the test extension and remove the setting-control element await extension.unload(); control.remove(); diff --git a/browser/components/preferences/widgets/setting-control/setting-control.mjs b/browser/components/preferences/widgets/setting-control/setting-control.mjs @@ -337,6 +337,10 @@ export class SettingControl extends SettingElement { }); } + get extensionSupportPage() { + return this.setting.controllingExtensionInfo.supportPage; + } + render() { // Allow the Setting to override the static config if necessary. this.config = this.setting.getControlConfig(this.config); @@ -359,11 +363,19 @@ export class SettingControl extends SettingElement { // there are no extensions controlling the setting. if (this.isControlledByExtension()) { let args = { name: this.extensionName }; + let supportPage = this.extensionSupportPage; messageBar = html`<moz-message-bar class="extension-controlled-message-bar" .messageL10nId=${this.extensionMessageId} .messageL10nArgs=${args} > + ${supportPage + ? html`<a + is="moz-support-link" + slot="support-link" + support-page=${supportPage} + ></a>` + : ""} <moz-button slot="actions" @click=${this.disableExtension} diff --git a/browser/components/preferences/widgets/setting-control/setting-control.stories.mjs b/browser/components/preferences/widgets/setting-control/setting-control.stories.mjs @@ -133,6 +133,7 @@ ExtensionControlled.args = { * extension-controlled-message = <strong>{ $name }</strong> requires Container Tabs. * */ l10nId: "extension-controlled-message", + supportPage: "preferences", }, }, setting: { @@ -149,6 +150,7 @@ ExtensionControlled.args = { id: "extension-controlled-example", l10nId: "extension-controlled-message", name: "My Extension", + supportPage: "preferences", }, }, }; diff --git a/browser/components/storybook/component-status/components.json b/browser/components/storybook/component-status/components.json @@ -1,6 +1,6 @@ { - "generatedAt": "2025-10-15T13:18:04.980Z", - "count": 28, + "generatedAt": "2025-11-12T19:18:35.085Z", + "count": 29, "items": [ { "component": "moz-badge", @@ -174,6 +174,15 @@ "bugUrl": "https://bugzilla.mozilla.org/show_bug.cgi?id=1837469" }, { + "component": "moz-page-header", + "title": "UI Widgets/Page Header", + "status": "in-development", + "storyId": "ui-widgets-page-header--default", + "storyUrl": "https://firefoxux.github.io/firefox-desktop-components/?path=/story/ui-widgets-page-header--default", + "sourceUrl": "https://searchfox.org/firefox-main/source/toolkit/content/widgets/moz-page-header", + "bugUrl": "" + }, + { "component": "moz-page-nav", "title": "UI Widgets/Page Nav", "status": "in-development", diff --git a/toolkit/content/preferences/Setting.mjs b/toolkit/content/preferences/Setting.mjs @@ -257,6 +257,7 @@ export class Setting extends EventEmitter { _clearControllingExtensionInfo() { delete this.controllingExtensionInfo.id; delete this.controllingExtensionInfo.name; + delete this.controllingExtensionInfo.supportPage; // Request an update to the setting control so the UI is in the correct state this.onChange(); } diff --git a/toolkit/content/widgets/moz-support-link/moz-support-link.mjs b/toolkit/content/widgets/moz-support-link/moz-support-link.mjs @@ -24,11 +24,7 @@ export default class MozSupportLink extends HTMLAnchorElement { * Handles setting up the SUPPORT_URL preference getter. * Without this, the tests for this component may not behave * as expected. -<<<<<<< HEAD -======= * - * @private ->>>>>>> b0875b52eeb8 (Bug 1998787 - Automatic fixes for enabling ESLint jsdoc/tag-line rule everywhere. r?#frontend-codestlye-reviewers) * @memberof MozSupportLink */ #register() {