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
This commit is contained in:
ganna 2023-06-07 14:27:39 +00:00
Родитель 8cece1119e
Коммит 72e33df199
5 изменённых файлов: 5 добавлений и 16 удалений

Просмотреть файл

@ -82,9 +82,6 @@ export class ExtensionControlledPopup {
* function is passed doc, message and addonDetails (the * function is passed doc, message and addonDetails (the
* add-on's icon and name). If not provided, then the add-on's * add-on's icon and name). If not provided, then the add-on's
* icon and name are added to the description. * 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 * @param {string} opts.learnMoreLink
* The name of the SUMO page to link to, this is added to * The name of the SUMO page to link to, this is added to
* app.support.baseURL. * app.support.baseURL.
@ -118,7 +115,6 @@ export class ExtensionControlledPopup {
this.descriptionId = opts.descriptionId; this.descriptionId = opts.descriptionId;
this.descriptionMessageId = opts.descriptionMessageId; this.descriptionMessageId = opts.descriptionMessageId;
this.getLocalizedDescription = opts.getLocalizedDescription; this.getLocalizedDescription = opts.getLocalizedDescription;
this.learnMoreMessageId = opts.learnMoreMessageId;
this.learnMoreLink = opts.learnMoreLink; this.learnMoreLink = opts.learnMoreLink;
this.preferencesLocation = opts.preferencesLocation; this.preferencesLocation = opts.preferencesLocation;
this.preferencesEntrypoint = opts.preferencesEntrypoint; this.preferencesEntrypoint = opts.preferencesEntrypoint;
@ -244,6 +240,8 @@ export class ExtensionControlledPopup {
return; return;
} }
win.ownerGlobal.ensureCustomElements("moz-support-link");
// Find the elements we need. // Find the elements we need.
let doc = win.document; let doc = win.document;
let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc); 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.setAttribute("class", "learnMore");
link.href = link.setAttribute("support-page", this.learnMoreLink);
Services.urlFormatter.formatURLPref("app.support.baseURL") +
this.learnMoreLink;
link.textContent = lazy.strBundle.GetStringFromName(
this.learnMoreMessageId
);
description.appendChild(link); description.appendChild(link);
} }

Просмотреть файл

@ -46,7 +46,6 @@ XPCOMUtils.defineLazyGetter(this, "homepagePopup", () => {
settingKey: HOMEPAGE_SETTING_NAME, settingKey: HOMEPAGE_SETTING_NAME,
descriptionId: "extension-homepage-notification-description", descriptionId: "extension-homepage-notification-description",
descriptionMessageId: "homepageControlled.message", descriptionMessageId: "homepageControlled.message",
learnMoreMessageId: "homepageControlled.learnMore",
learnMoreLink: "extension-home", learnMoreLink: "extension-home",
preferencesLocation: "home-homeOverride", preferencesLocation: "home-homeOverride",
preferencesEntrypoint: "addon-manage-home-override", preferencesEntrypoint: "addon-manage-home-override",

Просмотреть файл

@ -49,7 +49,6 @@ XPCOMUtils.defineLazyGetter(this, "tabHidePopup", () => {
image image
); );
}, },
learnMoreMessageId: "tabHideControlled.learnMore",
learnMoreLink: "extension-hiding-tabs", learnMoreLink: "extension-hiding-tabs",
}); });
}); });

Просмотреть файл

@ -35,7 +35,6 @@ XPCOMUtils.defineLazyGetter(this, "newTabPopup", () => {
settingKey: NEW_TAB_SETTING_NAME, settingKey: NEW_TAB_SETTING_NAME,
descriptionId: "extension-new-tab-notification-description", descriptionId: "extension-new-tab-notification-description",
descriptionMessageId: "newTabControlled.message2", descriptionMessageId: "newTabControlled.message2",
learnMoreMessageId: "newTabControlled.learnMore",
learnMoreLink: "extension-home", learnMoreLink: "extension-home",
preferencesLocation: "home-newtabOverride", preferencesLocation: "home-newtabOverride",
preferencesEntrypoint: "addon-manage-newtab-override", preferencesEntrypoint: "addon-manage-newtab-override",

Просмотреть файл

@ -83,7 +83,6 @@ add_task(async function testExtensionControlledPopup() {
settingKey, settingKey,
descriptionId: "extension-controlled-description", descriptionId: "extension-controlled-description",
descriptionMessageId: "newTabControlled.message2", descriptionMessageId: "newTabControlled.message2",
learnMoreMessageId: "newTabControlled.learnMore",
learnMoreLink: "extension-controlled", learnMoreLink: "extension-controlled",
onObserverAdded, onObserverAdded,
onObserverRemoved, 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", "An extension, Ext Controlled, changed the page you see when you open a new tab.Learn more",
"The extension name is in the description" "The extension name is in the description"
); );
let link = description.querySelector("label"); let link = description.querySelector("a.learnMore");
is( is(
link.href, link.href,
"http://127.0.0.1:8888/support-dummy/extension-controlled", "http://127.0.0.1:8888/support-dummy/extension-controlled",