/* 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"; const Telemetry = require("resource://devtools/client/shared/telemetry.js"); const { FrontClassWithSpec, registerFront, } = require("resource://devtools/shared/protocol.js"); const { inspectorSpec, } = require("resource://devtools/shared/specs/inspector.js"); loader.lazyRequireGetter( this, "captureScreenshot", "resource://devtools/client/shared/screenshot.js", true ); const TELEMETRY_EYEDROPPER_OPENED = "DEVTOOLS_EYEDROPPER_OPENED_COUNT"; const TELEMETRY_EYEDROPPER_OPENED_MENU = "DEVTOOLS_MENU_EYEDROPPER_OPENED_COUNT"; const SHOW_ALL_ANONYMOUS_CONTENT_PREF = "devtools.inspector.showAllAnonymousContent"; const telemetry = new Telemetry(); /** * Client side of the inspector actor, which is used to create * inspector-related actors, including the walker. */ class InspectorFront extends FrontClassWithSpec(inspectorSpec) { constructor(client, targetFront, parentFront) { super(client, targetFront, parentFront); this._client = client; this._highlighters = new Map(); // Attribute name from which to retrieve the actorID out of the target actor's form this.formAttributeName = "inspectorActor"; // Map of highlighter types to unsettled promises to create a highlighter of that type this._pendingGetHighlighterMap = new Map(); this.noopStylesheetListener = () => {}; } // async initialization async initialize() { if (this.initialized) { return this.initialized; } // Watch STYLESHEET resources to fill the ResourceCommand cache. // StyleRule front's `get parentStyleSheet()` will query the cache to // retrieve the resource corresponding to the parent stylesheet of a rule. const { resourceCommand } = this.targetFront.commands; // Backup resourceCommand, targetFront.commands might be null in `destroy`. this.resourceCommand = resourceCommand; await resourceCommand.watchResources([resourceCommand.TYPES.STYLESHEET], { onAvailable: this.noopStylesheetListener, }); // Bail out if the inspector is closed while watchResources was pending if (this.isDestroyed()) { return null; } this.initialized = await Promise.all([ this._getWalker(), this._getPageStyle(), ]); return this.initialized; } async _getWalker() { const showAllAnonymousContent = Services.prefs.getBoolPref( SHOW_ALL_ANONYMOUS_CONTENT_PREF ); this.walker = await this.getWalker({ showAllAnonymousContent, }); // We need to reparent the RootNode of remote iframe Walkers // so that their parent is the NodeFront of the