diff options
Diffstat (limited to 'browser/extensions/report-site-issue')
5 files changed, 30 insertions, 23 deletions
diff --git a/browser/extensions/report-site-issue/.eslintrc.js b/browser/extensions/report-site-issue/.eslintrc.js index a20deab67f..f710dd2f24 100644 --- a/browser/extensions/report-site-issue/.eslintrc.js +++ b/browser/extensions/report-site-issue/.eslintrc.js @@ -27,9 +27,6 @@ module.exports = { // Maximum depth callbacks can be nested. "max-nested-callbacks": ["error", 4], - // Allow the console API aside from console.log. - "no-console": ["error", { allow: ["error", "info", "trace", "warn"] }], - // Disallow use of multiline strings (use template strings instead). "no-multi-str": "error", diff --git a/browser/extensions/report-site-issue/background.js b/browser/extensions/report-site-issue/background.js index d495f33c25..8c8234e52f 100644 --- a/browser/extensions/report-site-issue/background.js +++ b/browser/extensions/report-site-issue/background.js @@ -18,24 +18,34 @@ const androidReporterConfig = { utm_source: "android-components-reporter", }; -let reporterConfig = desktopReporterConfig; +const getReporterConfig = (() => { + let promise; + return async () => { + promise ??= new Promise(resolve => { + browser.permissions + .contains({ permissions: ["nativeMessaging"] }) + .then(needProductName => { + if (needProductName) { + const port = browser.runtime.connectNative( + "mozacWebcompatReporter" + ); + port.onMessage.addListener(message => { + if ("productName" in message) { + androidReporterConfig.productName = message.productName; + resolve(androidReporterConfig); -(async () => { - const permissions = ["nativeMessaging"]; - if (await browser.permissions.contains({ permissions })) { - reporterConfig = androidReporterConfig; - - const port = browser.runtime.connectNative("mozacWebcompatReporter"); - port.onMessage.addListener(message => { - if ("productName" in message) { - reporterConfig.productName = message.productName; - - // For now, setting the productName is the only use for this port, and that's only happening - // once after startup, so let's disconnect the port when we're done. - port.disconnect(); - } + // For now, setting the productName is the only use for this port, and that's only happening + // once after startup, so let's disconnect the port when we're done. + port.disconnect(); + } + }); + } else { + resolve(desktopReporterConfig); + } + }); }); - } + return promise; + }; })(); async function loadTab(url) { @@ -60,6 +70,7 @@ async function captureAndSendReport(tab) { try { const { endpointUrl, webcompatInfo } = await browser.tabExtras.getWebcompatInfo(id); + const reporterConfig = await getReporterConfig(); const dataToSend = { endpointUrl, reportUrl: url, diff --git a/browser/extensions/report-site-issue/manifest.json b/browser/extensions/report-site-issue/manifest.json index 5108716475..aadf7917c7 100644 --- a/browser/extensions/report-site-issue/manifest.json +++ b/browser/extensions/report-site-issue/manifest.json @@ -3,7 +3,7 @@ "name": "WebCompat Reporter", "description": "Report site compatibility issues on webcompat.com", "author": "Thomas Wisniewski <twisniewski@mozilla.com>", - "version": "2.0.0", + "version": "2.1.0", "homepage_url": "https://github.com/mozilla/webcompat-reporter", "browser_specific_settings": { "gecko": { @@ -37,6 +37,8 @@ }, "permissions": ["tabs", "<all_urls>"], "background": { + "persistent": false, + "type": "module", "scripts": ["background.js"] } } diff --git a/browser/extensions/report-site-issue/test/browser/head.js b/browser/extensions/report-site-issue/test/browser/head.js index f4c74ab768..2af0485ff5 100644 --- a/browser/extensions/report-site-issue/test/browser/head.js +++ b/browser/extensions/report-site-issue/test/browser/head.js @@ -38,8 +38,6 @@ async function promiseAddonEnabled() { } class HelpMenuHelper { - #popup = null; - async open() { this.popup = document.getElementById("menu_HelpPopup"); ok(this.popup, "Help menu should exist"); diff --git a/browser/extensions/report-site-issue/test/browser/test.html b/browser/extensions/report-site-issue/test/browser/test.html index ed1844f530..b8811d8227 100644 --- a/browser/extensions/report-site-issue/test/browser/test.html +++ b/browser/extensions/report-site-issue/test/browser/test.html @@ -1,7 +1,6 @@ <!DOCTYPE html> <meta charset="utf-8"> <script> - /* eslint-disable no-console */ /* eslint-disable no-unused-expressions */ "use strict"; console.log(null); |