diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/extensions/report-site-issue/background.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/report-site-issue/background.js')
-rw-r--r-- | browser/extensions/report-site-issue/background.js | 43 |
1 files changed, 27 insertions, 16 deletions
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, |