From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../experimentalAPIs/tabExtras.js | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 browser/extensions/report-site-issue/experimentalAPIs/tabExtras.js (limited to 'browser/extensions/report-site-issue/experimentalAPIs/tabExtras.js') diff --git a/browser/extensions/report-site-issue/experimentalAPIs/tabExtras.js b/browser/extensions/report-site-issue/experimentalAPIs/tabExtras.js new file mode 100644 index 0000000000..48ef117630 --- /dev/null +++ b/browser/extensions/report-site-issue/experimentalAPIs/tabExtras.js @@ -0,0 +1,53 @@ +/* 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 */ + +const lazy = {}; + +const DEFAULT_NEW_REPORT_ENDPOINT = "https://webcompat.com/issues/new"; +const NEW_REPORT_ENDPOINT_PREF = + "ui.new-webcompat-reporter.new-report-endpoint"; + +this.tabExtras = class extends ExtensionAPI { + getAPI(context) { + const { tabManager } = context.extension; + const queryReportBrokenSiteActor = (tabId, name, params) => { + const { browser } = tabManager.get(tabId); + const windowGlobal = browser.browsingContext.currentWindowGlobal; + if (!windowGlobal) { + return null; + } + return windowGlobal.getActor("ReportBrokenSite").sendQuery(name, params); + }; + return { + tabExtras: { + async getWebcompatInfo(tabId) { + const endpointUrl = Services.prefs.getStringPref( + NEW_REPORT_ENDPOINT_PREF, + DEFAULT_NEW_REPORT_ENDPOINT + ); + const webcompatInfo = await queryReportBrokenSiteActor( + tabId, + "GetWebCompatInfo" + ); + return { + webcompatInfo, + endpointUrl, + }; + }, + async sendWebcompatInfo(tabId, info) { + console.error(info); + return queryReportBrokenSiteActor( + tabId, + "SendDataToWebcompatCom", + info + ); + }, + }, + }; + } +}; -- cgit v1.2.3