Bug 1297758 - Throw when accessing any unimplemented toolbox function when loading inspector in a tab. r=pbro draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 26 Sep 2016 07:08:00 -0700
changeset 418996 9382c2a6d1dd218dd2d3af506655389b66cc552f
parent 418995 9c501ea102d6401e86c2c4465423c426af5df503
child 418997 1852ce14384a47cc42a69112d90525658f1031e7
push id30810
push userbmo:poirot.alex@gmail.com
push dateThu, 29 Sep 2016 10:31:35 +0000
reviewerspbro
bugs1297758
milestone52.0a1
Bug 1297758 - Throw when accessing any unimplemented toolbox function when loading inspector in a tab. r=pbro MozReview-Commit-ID: AsI0Fluyu7j
devtools/client/inspector/inspector.js
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -1836,16 +1836,19 @@ if (url.search.length > 1) {
 
   const { Selection } = require("devtools/client/framework/selection");
   const { InspectorFront } = require("devtools/shared/fronts/inspector");
   const { getHighlighterUtils } = require("devtools/client/framework/toolbox-highlighter-utils");
 
   Task.spawn(function* () {
     let target = yield targetFromURL(url);
 
+    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: BrowserLoader({
@@ -1856,16 +1859,31 @@ if (url.search.length > 1) {
         return this.browserRequire("devtools/client/shared/vendor/react");
       },
       get ReactDOM() {
         return this.browserRequire("devtools/client/shared/vendor/react-dom");
       },
       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,
+
       // For attachThread:
       highlightTool() {},
       unhighlightTool() {},
       selectTool() {},
       raise() {},
       getNotificationBox() {}
     };