From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- dom/browser-element/BrowserElementChild.js | 42 ++ dom/browser-element/BrowserElementChildPreload.js | 290 +++++++++ dom/browser-element/BrowserElementParent.jsm | 276 ++++++++ .../BrowserElementPromptService.jsm | 723 +++++++++++++++++++++ dom/browser-element/components.conf | 14 + dom/browser-element/moz.build | 37 ++ dom/browser-element/nsIBrowserElementAPI.idl | 44 ++ 7 files changed, 1426 insertions(+) create mode 100644 dom/browser-element/BrowserElementChild.js create mode 100644 dom/browser-element/BrowserElementChildPreload.js create mode 100644 dom/browser-element/BrowserElementParent.jsm create mode 100644 dom/browser-element/BrowserElementPromptService.jsm create mode 100644 dom/browser-element/components.conf create mode 100644 dom/browser-element/moz.build create mode 100644 dom/browser-element/nsIBrowserElementAPI.idl (limited to 'dom/browser-element') diff --git a/dom/browser-element/BrowserElementChild.js b/dom/browser-element/BrowserElementChild.js new file mode 100644 index 0000000000..762957bcd4 --- /dev/null +++ b/dom/browser-element/BrowserElementChild.js @@ -0,0 +1,42 @@ +/* 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/. */ + +/* eslint-env mozilla/frame-script */ +/* global api, CopyPasteAssistent */ + +"use strict"; + +function debug(msg) { + // dump("BrowserElementChild - " + msg + "\n"); +} + +var BrowserElementIsReady; + +debug(`Might load BE scripts: BEIR: ${BrowserElementIsReady}`); +if (!BrowserElementIsReady) { + debug("Loading BE scripts"); + if (!("BrowserElementIsPreloaded" in this)) { + Services.scriptloader.loadSubScript( + "chrome://global/content/BrowserElementChildPreload.js", + this + ); + } + + function onDestroy() { + removeMessageListener("browser-element-api:destroy", onDestroy); + + if (api) { + api.destroy(); + } + + BrowserElementIsReady = false; + } + addMessageListener("browser-element-api:destroy", onDestroy); + + BrowserElementIsReady = true; +} else { + debug("BE already loaded, abort"); +} + +sendAsyncMessage("browser-element-api:call", { msg_name: "hello" }); diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js new file mode 100644 index 0000000000..1bbcf9ff05 --- /dev/null +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -0,0 +1,290 @@ +/* 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"; + +/* eslint-env mozilla/frame-script */ + +function debug(msg) { + // dump("BrowserElementChildPreload - " + msg + "\n"); +} + +debug("loaded"); + +var BrowserElementIsReady; + +var { BrowserElementPromptService } = ChromeUtils.import( + "resource://gre/modules/BrowserElementPromptService.jsm" +); + +function sendAsyncMsg(msg, data) { + // Ensure that we don't send any messages before BrowserElementChild.js + // finishes loading. + if (!BrowserElementIsReady) { + return; + } + + if (!data) { + data = {}; + } + + data.msg_name = msg; + sendAsyncMessage("browser-element-api:call", data); +} + +var LISTENED_EVENTS = [ + // This listens to unload events from our message manager, but /not/ from + // the |content| window. That's because the window's unload event doesn't + // bubble, and we're not using a capturing listener. If we'd used + // useCapture == true, we /would/ hear unload events from the window, which + // is not what we want! + { type: "unload", useCapture: false, wantsUntrusted: false }, +]; + +/** + * The BrowserElementChild implements one half of