MessageHandlerFrameActor.sys.mjs (1768B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 const lazy = {}; 6 7 ChromeUtils.defineESModuleGetters(lazy, { 8 ActorManagerParent: "resource://gre/modules/ActorManagerParent.sys.mjs", 9 10 Log: "chrome://remote/content/shared/Log.sys.mjs", 11 RemoteAgent: "chrome://remote/content/components/RemoteAgent.sys.mjs", 12 }); 13 14 ChromeUtils.defineLazyGetter(lazy, "logger", () => lazy.Log.get()); 15 16 const FRAME_ACTOR_CONFIG = { 17 parent: { 18 esModuleURI: 19 "chrome://remote/content/shared/messagehandler/transports/js-window-actors/MessageHandlerFrameParent.sys.mjs", 20 }, 21 child: { 22 esModuleURI: 23 "chrome://remote/content/shared/messagehandler/transports/js-window-actors/MessageHandlerFrameChild.sys.mjs", 24 events: { 25 DOMWindowCreated: {}, 26 pagehide: {}, 27 pageshow: {}, 28 }, 29 }, 30 allFrames: true, 31 }; 32 33 // Bug 1713440: Workaround until the MessageHandler 34 // supports chrome browsing contexts. 35 if (lazy.RemoteAgent.allowSystemAccess) { 36 FRAME_ACTOR_CONFIG.includeChrome = true; 37 } else { 38 // Without system access limit loading the actor for content browsers only. 39 FRAME_ACTOR_CONFIG.messageManagerGroups = ["browsers"]; 40 } 41 42 /** 43 * MessageHandlerFrameActor exposes a simple registration helper to lazily 44 * register MessageHandlerFrame JSWindow actors. 45 */ 46 export const MessageHandlerFrameActor = { 47 registered: false, 48 49 register() { 50 if (this.registered) { 51 return; 52 } 53 54 lazy.ActorManagerParent.addJSWindowActors({ 55 MessageHandlerFrame: FRAME_ACTOR_CONFIG, 56 }); 57 this.registered = true; 58 lazy.logger.trace("Registered MessageHandlerFrame actors"); 59 }, 60 };