Bug 1696490 - Fix errors loading report-site-issue builtin extension triggered by pageActionExtras.js due to the pageAction removal. r=mconley,denschub,webcompat-reviewers

This patch does remove the pageActionExtras experimental API, which is what started triggering
those errors after the pageAction manifest property was removed from the manifest in Bug 1690573:

- The pageActionExtras API was internally retrieving the pageAction API class
  (see https://searchfox.org/mozilla-central/rev/eeb8cf278192d68b3977d0adb4d43f1463439269/browser/extensions/report-site-issue/experimentalAPIs/pageActionExtras.js#12-16)
  which is a bit of an hack and it used to work because there was a pageAction property in the
  manifest.json file (and that was what used to guarantee that the ext-pageAction.js API module
  was always loaded before the background page of the extension did have a chance to run)

- In Bug 1690573 we removed the pageAction property from the manifest and as a side-effect the
  ext-pageAction.js module wouldn't be loaded anymore, which did break the assumption in
  the pageActionExtras API (and the extension background page script as a side effect of that)

I assume that if we removed the pageAction from the manifest, then we don't need the pageActionExtras
experimental API neither (it seems that its purpose was to localize the pageAction and to set a custom
telemetry label for it) and so to fix the regression I opted to remove the remaining traces of the
pageActionExtras experimental API.

NOTE: there are some more traces left in head.js, which are used for the test cases.
All the tests are currently disabled and it seems that they are meant to be re-enabled
as part or as a follow up of Bug 1693119 and so I think that for those parts we can
wait to get there.

Differential Revision: https://phabricator.services.mozilla.com/D107326
This commit is contained in:
Luca Greco 2021-03-08 16:32:18 +00:00
parent d2b0d77574
commit 14ac3915d9
5 changed files with 0 additions and 104 deletions

View File

@ -17,8 +17,6 @@ const Config = {
const FRAMEWORK_KEYS = ["hasFastClick", "hasMobify", "hasMarfeel"];
browser.pageActionExtras.setLabelForHistogram("webcompat");
browser.helpMenu.onHelpMenuCommand.addListener(tab => {
return getWebCompatInfoForTab(tab).then(
info => {
@ -156,14 +154,6 @@ function stripNonASCIIChars(str) {
return str.replace(/[^\x00-\x7F]/g, "");
}
browser.l10n
.getMessage("wc-reporter.label2")
.then(browser.pageActionExtras.setDefaultTitle, () => {});
browser.l10n
.getMessage("wc-reporter.tooltip")
.then(browser.pageActionExtras.setTooltipText, () => {});
async function openWebCompatTab(compatInfo) {
const url = new URL(Config.newIssueEndpoint);
const { details } = compatInfo;

View File

@ -1,43 +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/. */
"use strict";
/* global ExtensionAPI */
this.pageActionExtras = class extends ExtensionAPI {
getAPI(context) {
const extension = context.extension;
const pageActionAPI = extension.apiManager.getAPI(
"pageAction",
extension,
context.envType
);
const {
Management: {
global: { windowTracker },
},
} = ChromeUtils.import("resource://gre/modules/Extension.jsm", null);
return {
pageActionExtras: {
async setDefaultTitle(title) {
pageActionAPI.action.getContextData(null).title = title;
// Make sure the new default title is considered right away
for (const window of windowTracker.browserWindows()) {
const tab = window.gBrowser.selectedTab;
if (pageActionAPI.action.isShownForTab(tab)) {
pageActionAPI.updateButton(window);
}
}
},
async setLabelForHistogram(label) {
pageActionAPI.browserPageAction._labelForHistogram = label;
},
async setTooltipText(text) {
pageActionAPI.browserPageAction.setTooltip(text);
},
},
};
}
};

View File

@ -1,41 +0,0 @@
[
{
"namespace": "pageActionExtras",
"description": "experimental pageAction API extensions",
"functions": [
{
"name": "setDefaultTitle",
"type": "function",
"async": true,
"description": "Set the page action's title for all tabs",
"parameters": [{
"name": "title",
"type": "string",
"description": "title"
}]
},
{
"name": "setLabelForHistogram",
"type": "function",
"async": true,
"description": "Set the page action's label for telemetry histograms",
"parameters": [{
"name": "label",
"type": "string",
"description": "label for the histogram"
}]
},
{
"name": "setTooltipText",
"type": "function",
"async": true,
"description": "Set the page action's tooltip text",
"parameters": [{
"name": "text",
"type": "string",
"description": "text"
}]
}
]
}
]

View File

@ -43,14 +43,6 @@
"paths": [["l10n"]]
}
},
"pageActionExtras": {
"schema": "experimentalAPIs/pageActionExtras.json",
"parent": {
"scopes": ["addon_parent"],
"script": "experimentalAPIs/pageActionExtras.js",
"paths": [["pageActionExtras"]]
}
},
"tabExtras": {
"schema": "experimentalAPIs/tabExtras.json",
"parent": {

View File

@ -23,8 +23,6 @@ FINAL_TARGET_FILES.features["webcompat-reporter@mozilla.org"].experimentalAPIs +
"experimentalAPIs/helpMenu.json",
"experimentalAPIs/l10n.js",
"experimentalAPIs/l10n.json",
"experimentalAPIs/pageActionExtras.js",
"experimentalAPIs/pageActionExtras.json",
"experimentalAPIs/tabExtras.js",
"experimentalAPIs/tabExtras.json",
]