Bug 1456075 - Remove standalone inspector initialization code;r=ochameau
MozReview-Commit-ID: 6uwKogI7079
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -2431,120 +2431,9 @@ Inspector.prototype = {
return false;
}
await this.selection.setNodeFront(nodeFront, { reason: inspectFromAnnotation });
return true;
},
};
-/**
- * Create a fake toolbox when running the inspector standalone, either in a chrome tab or
- * in a content tab.
- *
- * @param {Target} target to debug
- * @param {Function} createThreadClient
- * When supported the thread client needs a reference to the toolbox.
- * This callback will be called right after the toolbox object is created.
- * @param {Object} dependencies
- * - react
- * - reactDOM
- * - browserRequire
- */
-const buildFakeToolbox = async function(
- target, createThreadClient, {
- React,
- ReactDOM,
- browserRequire
- }) {
- const { InspectorFront } = require("devtools/shared/fronts/inspector");
- const { Selection } = require("devtools/client/framework/selection");
- const { getHighlighterUtils } = require("devtools/client/framework/toolbox-highlighter-utils");
-
- let notImplemented = function() {
- throw new Error("Not implemented in a tab");
- };
- let fakeToolbox = {
- target,
- hostType: "bottom",
- doc: window.document,
- win: window,
- on() {}, emit() {}, off() {},
- initInspector() {},
- browserRequire,
- React,
- ReactDOM,
- isToolRegistered() {
- return false;
- },
- currentToolId: "inspector",
- getCurrentPanel() {
- return "inspector";
- },
- get textboxContextMenuPopup() {
- notImplemented();
- },
- getPanel: notImplemented,
- openSplitConsole: notImplemented,
- viewCssSourceInStyleEditor: notImplemented,
- viewJsSourceInDebugger: notImplemented,
- viewSource: notImplemented,
- viewSourceInDebugger: notImplemented,
- viewSourceInStyleEditor: notImplemented,
-
- get inspectorExtensionSidebars() {
- notImplemented();
- },
-
- // For attachThread:
- highlightTool() {},
- unhighlightTool() {},
- selectTool() {},
- raise() {},
- getNotificationBox() {}
- };
-
- fakeToolbox.threadClient = await createThreadClient(fakeToolbox);
-
- let inspector = InspectorFront(target.client, target.form);
- let showAllAnonymousContent =
- Services.prefs.getBoolPref("devtools.inspector.showAllAnonymousContent");
- let walker = await inspector.getWalker({ showAllAnonymousContent });
- let selection = new Selection(walker);
- let highlighter = await inspector.getHighlighter(false);
- fakeToolbox.highlighterUtils = getHighlighterUtils(fakeToolbox);
-
- fakeToolbox.inspector = inspector;
- fakeToolbox.walker = walker;
- fakeToolbox.selection = selection;
- fakeToolbox.highlighter = highlighter;
- return fakeToolbox;
-};
-
-// URL constructor doesn't support chrome: scheme
-let href = window.location.href.replace(/chrome:/, "http://");
-let url = new window.URL(href);
-
-// If query parameters are given in a chrome tab, the inspector is running in standalone.
-if (window.location.protocol === "chrome:" && url.search.length > 1) {
- const { targetFromURL } = require("devtools/client/framework/target-from-url");
- const { attachThread } = require("devtools/client/framework/attach-thread");
-
- const browserRequire = BrowserLoader({ window, useOnlyShared: true }).require;
- const React = browserRequire("devtools/client/shared/vendor/react");
- const ReactDOM = browserRequire("devtools/client/shared/vendor/react-dom");
-
- (async function() {
- let target = await targetFromURL(url);
- let fakeToolbox = await buildFakeToolbox(
- target,
- (toolbox) => attachThread(toolbox),
- { React, ReactDOM, browserRequire }
- );
- let inspectorUI = new Inspector(fakeToolbox);
- inspectorUI.init();
- })().catch(e => {
- window.alert("Unable to start the inspector:" + e.message + "\n" + e.stack);
- });
-}
-
exports.Inspector = Inspector;
-exports.buildFakeToolbox = buildFakeToolbox;