summaryrefslogtreecommitdiffstats
path: root/browser/extensions/report-site-issue/experimentalAPIs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /browser/extensions/report-site-issue/experimentalAPIs
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/report-site-issue/experimentalAPIs')
-rw-r--r--browser/extensions/report-site-issue/experimentalAPIs/helpMenu.js38
-rw-r--r--browser/extensions/report-site-issue/experimentalAPIs/helpMenu.json28
-rw-r--r--browser/extensions/report-site-issue/experimentalAPIs/tabExtras.js53
-rw-r--r--browser/extensions/report-site-issue/experimentalAPIs/tabExtras.json37
4 files changed, 156 insertions, 0 deletions
diff --git a/browser/extensions/report-site-issue/experimentalAPIs/helpMenu.js b/browser/extensions/report-site-issue/experimentalAPIs/helpMenu.js
new file mode 100644
index 0000000000..804f4b08d5
--- /dev/null
+++ b/browser/extensions/report-site-issue/experimentalAPIs/helpMenu.js
@@ -0,0 +1,38 @@
+/* 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, ExtensionCommon, Services */
+
+const TOPIC = "report-site-issue";
+
+this.helpMenu = class extends ExtensionAPI {
+ getAPI(context) {
+ const { tabManager } = context.extension;
+ let EventManager = ExtensionCommon.EventManager;
+
+ return {
+ helpMenu: {
+ onHelpMenuCommand: new EventManager({
+ context,
+ name: "helpMenu",
+ register: fire => {
+ let observer = (subject, topic, data) => {
+ let nativeTab = subject.wrappedJSObject;
+ let tab = tabManager.convert(nativeTab);
+ fire.async(tab);
+ };
+
+ Services.obs.addObserver(observer, TOPIC);
+
+ return () => {
+ Services.obs.removeObserver(observer, TOPIC);
+ };
+ },
+ }).api(),
+ },
+ };
+ }
+};
diff --git a/browser/extensions/report-site-issue/experimentalAPIs/helpMenu.json b/browser/extensions/report-site-issue/experimentalAPIs/helpMenu.json
new file mode 100644
index 0000000000..e7c3a8c405
--- /dev/null
+++ b/browser/extensions/report-site-issue/experimentalAPIs/helpMenu.json
@@ -0,0 +1,28 @@
+[
+ {
+ "namespace": "helpMenu",
+ "events": [
+ {
+ "name": "onHelpMenuCommand",
+ "type": "function",
+ "async": "callback",
+ "description": "Fired when the command event for the Report Site Issue menuitem in Help is fired.",
+ "parameters": [
+ {
+ "type": "function",
+ "name": "callback",
+ "optional": true,
+ "parameters": [
+ {
+ "name": "tab",
+ "$ref": "tabs.Tab",
+ "optional": true,
+ "description": "Details about the selected tab in the window where the menuitem command fired."
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+]
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
+ );
+ },
+ },
+ };
+ }
+};
diff --git a/browser/extensions/report-site-issue/experimentalAPIs/tabExtras.json b/browser/extensions/report-site-issue/experimentalAPIs/tabExtras.json
new file mode 100644
index 0000000000..5e0098ab32
--- /dev/null
+++ b/browser/extensions/report-site-issue/experimentalAPIs/tabExtras.json
@@ -0,0 +1,37 @@
+[
+ {
+ "namespace": "tabExtras",
+ "description": "experimental tab API extensions",
+ "functions": [
+ {
+ "name": "getWebcompatInfo",
+ "type": "function",
+ "description": "Gets the content blocking status and script log for a given tab",
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "tabId",
+ "minimum": 0
+ }
+ ],
+ "async": true
+ },
+ {
+ "name": "sendWebcompatInfo",
+ "type": "function",
+ "description": "Sends the given webcompat info to the given tab",
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "tabId",
+ "minimum": 0
+ },
+ {
+ "type": "any"
+ }
+ ],
+ "async": true
+ }
+ ]
+ }
+]