/* 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" ); var kLongestReturnedString = 128; var Timer = Components.Constructor( "@mozilla.org/timer;1", "nsITimer", "initWithCallback" ); 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); } function sendSyncMsg(msg, data) { // Ensure that we don't send any messages before BrowserElementChild.js // finishes loading. if (!BrowserElementIsReady) { return undefined; } if (!data) { data = {}; } data.msg_name = msg; return sendSyncMessage("browser-element-api:call", data); } var CERTIFICATE_ERROR_PAGE_PREF = "security.alternate_certificate_error_page"; var OBSERVED_EVENTS = [ "xpcom-shutdown", "audio-playback", "activity-done", "will-launch-app", ]; var LISTENED_EVENTS = [ { type: "DOMTitleChanged", useCapture: true, wantsUntrusted: false }, { type: "DOMLinkAdded", useCapture: true, wantsUntrusted: false }, { type: "MozScrolledAreaChanged", useCapture: true, wantsUntrusted: false }, { type: "MozDOMFullscreen:Request", useCapture: true, wantsUntrusted: false }, { type: "MozDOMFullscreen:NewOrigin", useCapture: true, wantsUntrusted: false, }, { type: "MozDOMFullscreen:Exit", useCapture: true, wantsUntrusted: false }, { type: "DOMMetaAdded", useCapture: true, wantsUntrusted: false }, { type: "DOMMetaChanged", useCapture: true, wantsUntrusted: false }, { type: "DOMMetaRemoved", useCapture: true, wantsUntrusted: false }, { type: "scrollviewchange", useCapture: true, wantsUntrusted: false }, { type: "click", useCapture: false, wantsUntrusted: false }, // 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 }, ]; // We are using the system group for those events so if something in the // content called .stopPropagation() this will still be called. var LISTENED_SYSTEM_EVENTS = [ { type: "DOMWindowClose", useCapture: false }, { type: "DOMWindowCreated", useCapture: false }, { type: "DOMWindowResize", useCapture: false }, { type: "contextmenu", useCapture: false }, { type: "scroll", useCapture: false }, ]; /** * The BrowserElementChild implements one half of