зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1881803 - convert Report Site Issue extension to event pages; r=robwu,webcompat-reviewers,ksenia
Differential Revision: https://phabricator.services.mozilla.com/D202602
This commit is contained in:
Родитель
c722636351
Коммит
dd33e85ad8
|
@ -18,24 +18,34 @@ const androidReporterConfig = {
|
|||
utm_source: "android-components-reporter",
|
||||
};
|
||||
|
||||
let reporterConfig = desktopReporterConfig;
|
||||
|
||||
(async () => {
|
||||
const permissions = ["nativeMessaging"];
|
||||
if (await browser.permissions.contains({ permissions })) {
|
||||
reporterConfig = androidReporterConfig;
|
||||
|
||||
const port = browser.runtime.connectNative("mozacWebcompatReporter");
|
||||
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) {
|
||||
reporterConfig.productName = message.productName;
|
||||
androidReporterConfig.productName = message.productName;
|
||||
resolve(androidReporterConfig);
|
||||
|
||||
// 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,
|
||||
|
|
|
@ -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"]
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче