ParentWindowGlobalTarget(browsingContextID) { const id = await this.getParentBrowsingContextID(browsingContextID); if (!id) { return null; } return this.getWindowGlobalTarget(id); } /** * Memoized getter for the "blackboxing" actor */ async getBlackboxingActor() { if (!this._blackboxingActor) { this._blackboxingActor = await super.getBlackboxingActor(); } return this._blackboxingActor; } /** * Memoized getter for the "breakpoint-list" actor */ async getBreakpointListActor() { if (!this._breakpointListActor) { this._breakpointListActor = await super.getBreakpointListActor(); } return this._breakpointListActor; } /** * Memoized getter for the "target-configuration" actor */ async getTargetConfigurationActor() { if (!this._targetConfigurationActor) { this._targetConfigurationActor = await super.getTargetConfigurationActor(); } return this._targetConfigurationActor; } /** * Memoized getter for the "thread-configuration" actor */ async getThreadConfigurationActor() { if (!this._threadConfigurationActor) { this._threadConfigurationActor = await super.getThreadConfigurationActor(); } return this._threadConfigurationActor; } /** * For a given BrowsingContext ID, return the already existing WindowGlobalTargetFront */ async getWindowGlobalTarget(id) { // First scan the watcher children as the watcher manages all the targets for (const front of this.poolChildren()) { if (front.browsingContextID == id) { return front; } } // But the top level target will be created by the Descriptor.getTarget() method // and so be hosted in the Descriptor's pool. // The parent front of the WatcherActor happens to be the Descriptor Actor. // This code could go away or be simplified if the Descriptor starts fetch all // the targets, including the top level one via the Watcher. i.e. drop Descriptor.getTarget(). const topLevelTarget = await this.parentFront.getTarget(); if (topLevelTarget?.browsingContextID == id) { return topLevelTarget; } // If we could not find a window global target for the provided id, the // window global might not be the topmost one of a given process (isProcessRoot == true). // For now we only create targets for the top window global of each process, // so we recursively check the parent browsing context ids // until we find a valid target. const parentBrowsingContextID = await this.getParentBrowsingContextID(id); if (parentBrowsingContextID && parentBrowsingContextID !== id) { return this.getWindowGlobalTarget(parentBrowsingContextID); } return null; } getWindowGlobalTargetByInnerWindowId(innerWindowId) { for (const front of this.poolChildren()) { if (front.innerWindowId == innerWindowId) { return front; } } // Use getCachedTarget in order to have a fully synchronous method // as the callsite in ResourceCommand benefit from being synchronous. // Here we care only about already existing resource and do not need to // wait for the next target to come. const topLevelTarget = this.parentFront.getCachedTarget(); if (topLevelTarget?.innerWindowId == innerWindowId) { return topLevelTarget; } console.error("Unable to find target with innerWindowId:" + innerWindowId); return null; } /** * Memoized getter for the "networkParent" actor */ async getNetworkParentActor() { if (!this._networkParentActor) { this._networkParentActor = await super.getNetworkParentActor(); } return this._networkParentActor; } } registerFront(WatcherFront); PK