From 72e33df19930a5618440f8aa809174e6338ba2df Mon Sep 17 00:00:00 2001 From: ganna Date: Wed, 7 Jun 2023 14:27:39 +0000 Subject: [PATCH] Bug 1814414 - Replace constructed xul label with moz-support-link in ExtensionControlledPopup.jsm r=extension-reviewers,robwu Differential Revision: https://phabricator.services.mozilla.com/D179835 --- .../extensions/ExtensionControlledPopup.sys.mjs | 15 ++++----------- .../parent/ext-chrome-settings-overrides.js | 1 - browser/components/extensions/parent/ext-tabs.js | 1 - .../extensions/parent/ext-url-overrides.js | 1 - .../browser/browser_ExtensionControlledPopup.js | 3 +-- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/browser/components/extensions/ExtensionControlledPopup.sys.mjs b/browser/components/extensions/ExtensionControlledPopup.sys.mjs index 024235e8bc44..35eefc4c1bf8 100644 --- a/browser/components/extensions/ExtensionControlledPopup.sys.mjs +++ b/browser/components/extensions/ExtensionControlledPopup.sys.mjs @@ -82,9 +82,6 @@ export class ExtensionControlledPopup { * function is passed doc, message and addonDetails (the * add-on's icon and name). If not provided, then the add-on's * icon and name are added to the description. - * @param {string} opts.learnMoreMessageId - * The message id to be used for the text of a "learn more" link which - * will be placed after the description. * @param {string} opts.learnMoreLink * The name of the SUMO page to link to, this is added to * app.support.baseURL. @@ -118,7 +115,6 @@ export class ExtensionControlledPopup { this.descriptionId = opts.descriptionId; this.descriptionMessageId = opts.descriptionMessageId; this.getLocalizedDescription = opts.getLocalizedDescription; - this.learnMoreMessageId = opts.learnMoreMessageId; this.learnMoreLink = opts.learnMoreLink; this.preferencesLocation = opts.preferencesLocation; this.preferencesEntrypoint = opts.preferencesEntrypoint; @@ -244,6 +240,8 @@ export class ExtensionControlledPopup { return; } + win.ownerGlobal.ensureCustomElements("moz-support-link"); + // Find the elements we need. let doc = win.document; let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc); @@ -359,14 +357,9 @@ export class ExtensionControlledPopup { ); } - let link = doc.createXULElement("label", { is: "text-link" }); + let link = doc.createElement("a", { is: "moz-support-link" }); link.setAttribute("class", "learnMore"); - link.href = - Services.urlFormatter.formatURLPref("app.support.baseURL") + - this.learnMoreLink; - link.textContent = lazy.strBundle.GetStringFromName( - this.learnMoreMessageId - ); + link.setAttribute("support-page", this.learnMoreLink); description.appendChild(link); } diff --git a/browser/components/extensions/parent/ext-chrome-settings-overrides.js b/browser/components/extensions/parent/ext-chrome-settings-overrides.js index 6c9b35d66c42..f5bbd8131012 100644 --- a/browser/components/extensions/parent/ext-chrome-settings-overrides.js +++ b/browser/components/extensions/parent/ext-chrome-settings-overrides.js @@ -46,7 +46,6 @@ XPCOMUtils.defineLazyGetter(this, "homepagePopup", () => { settingKey: HOMEPAGE_SETTING_NAME, descriptionId: "extension-homepage-notification-description", descriptionMessageId: "homepageControlled.message", - learnMoreMessageId: "homepageControlled.learnMore", learnMoreLink: "extension-home", preferencesLocation: "home-homeOverride", preferencesEntrypoint: "addon-manage-home-override", diff --git a/browser/components/extensions/parent/ext-tabs.js b/browser/components/extensions/parent/ext-tabs.js index c8d6b9f6ddbb..33aec14bc143 100644 --- a/browser/components/extensions/parent/ext-tabs.js +++ b/browser/components/extensions/parent/ext-tabs.js @@ -49,7 +49,6 @@ XPCOMUtils.defineLazyGetter(this, "tabHidePopup", () => { image ); }, - learnMoreMessageId: "tabHideControlled.learnMore", learnMoreLink: "extension-hiding-tabs", }); }); diff --git a/browser/components/extensions/parent/ext-url-overrides.js b/browser/components/extensions/parent/ext-url-overrides.js index 07e35441ef38..9e9380bb49ef 100644 --- a/browser/components/extensions/parent/ext-url-overrides.js +++ b/browser/components/extensions/parent/ext-url-overrides.js @@ -35,7 +35,6 @@ XPCOMUtils.defineLazyGetter(this, "newTabPopup", () => { settingKey: NEW_TAB_SETTING_NAME, descriptionId: "extension-new-tab-notification-description", descriptionMessageId: "newTabControlled.message2", - learnMoreMessageId: "newTabControlled.learnMore", learnMoreLink: "extension-home", preferencesLocation: "home-newtabOverride", preferencesEntrypoint: "addon-manage-newtab-override", diff --git a/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js b/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js index c920bf75b5ee..b9f91b4ba478 100644 --- a/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js +++ b/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js @@ -83,7 +83,6 @@ add_task(async function testExtensionControlledPopup() { settingKey, descriptionId: "extension-controlled-description", descriptionMessageId: "newTabControlled.message2", - learnMoreMessageId: "newTabControlled.learnMore", learnMoreLink: "extension-controlled", onObserverAdded, onObserverRemoved, @@ -162,7 +161,7 @@ add_task(async function testExtensionControlledPopup() { "An extension, Ext Controlled, changed the page you see when you open a new tab.Learn more", "The extension name is in the description" ); - let link = description.querySelector("label"); + let link = description.querySelector("a.learnMore"); is( link.href, "http://127.0.0.1:8888/support-dummy/extension-controlled",