log.sys.mjs (1236B)
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 import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs"; 6 7 const lazy = {}; 8 9 ChromeUtils.defineESModuleGetters(lazy, { 10 NavigableManager: "chrome://remote/content/shared/NavigableManager.sys.mjs", 11 processExtraData: 12 "chrome://remote/content/webdriver-bidi/modules/Intercept.sys.mjs", 13 TabManager: "chrome://remote/content/shared/TabManager.sys.mjs", 14 }); 15 16 class LogModule extends Module { 17 destroy() {} 18 19 interceptEvent(name, payload) { 20 if (name == "log.entryAdded") { 21 const browsingContext = payload.source.context; 22 if (!lazy.TabManager.isValidCanonicalBrowsingContext(browsingContext)) { 23 // Discard events for invalid browsing contexts. 24 return null; 25 } 26 27 // Resolve browsing context to a Navigable id. 28 payload.source.context = 29 lazy.NavigableManager.getIdForBrowsingContext(browsingContext); 30 31 payload = lazy.processExtraData(this.messageHandler.sessionId, payload); 32 } 33 34 return payload; 35 } 36 } 37 38 export const log = LogModule;