From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- dom/browser-element/BrowserElementChildPreload.js | 288 ++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 dom/browser-element/BrowserElementChildPreload.js (limited to 'dom/browser-element/BrowserElementChildPreload.js') diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js new file mode 100644 index 0000000000..4ded6ce02a --- /dev/null +++ b/dom/browser-element/BrowserElementChildPreload.js @@ -0,0 +1,288 @@ +/* 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 { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +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