Bug 1295753 - Fix console interaction with new debugger r=jlongster
authorJason Laster <jlaster@mozilla.com>
Tue, 06 Sep 2016 09:34:50 -0400
changeset 312844 9748e79666b98653302f93b7f4d9691c35d1f7aa
parent 312843 863ce9e133e8dd11916315a0d2dab8ec05de2825
child 312845 e403c34977380158c098158767c990849316a9fd
push id30662
push userkwierso@gmail.com
push dateWed, 07 Sep 2016 00:34:56 +0000
treeherdermozilla-central@91c2b9d5c135 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlongster
bugs1295753
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1295753 - Fix console interaction with new debugger r=jlongster
devtools/client/debugger/new/panel.js
devtools/client/debugger/panel.js
devtools/client/webconsole/hudservice.js
--- a/devtools/client/debugger/new/panel.js
+++ b/devtools/client/debugger/new/panel.js
@@ -13,22 +13,59 @@ DebuggerPanel.prototype = {
     let targetPromise;
     if (!this.toolbox.target.isRemote) {
       targetPromise = this.toolbox.target.makeRemote();
     } else {
       targetPromise = promise.resolve(this.toolbox.target);
     }
 
     return targetPromise.then(() => {
-      const dbg = this.panelWin.Debugger;
-      dbg.setThreadClient(this.toolbox.threadClient);
-      dbg.setTabTarget(this.toolbox.target);
-      dbg.initPage(dbg.getActions());
-      dbg.renderApp();
+      this.panelWin.Debugger.bootstrap({
+        threadClient: this.toolbox.threadClient,
+        tabTarget: this.toolbox.target
+      });
       return this;
     });
   },
 
+  _store: function() {
+    return this.panelWin.Debugger.store;
+  },
+
+  _getState: function() {
+    return this._store().getState();
+  },
+
+  _actions: function() {
+    return this.panelWin.Debugger.actions;
+  },
+
+  _selectors: function() {
+    return this.panelWin.Debugger.selectors;
+  },
+
+  getFrames: function() {
+    let frames = this._selectors().getFrames(this._getState());
+
+    // frames is an empty array when the debugger is not paused
+    if (!frames.toJS) {
+      return {
+        frames: [],
+        selected: -1
+      }
+    }
+
+    frames = frames.toJS();
+    const selectedFrame = this._selectors().getSelectedFrame(this._getState());
+    const selected = frames.findIndex(frame => frame.id == selectedFrame.id);
+
+    frames.forEach(frame => {
+      frame.actor = frame.id;
+    });
+
+    return { frames, selected };
+  },
+
   destroy: function() {
   }
 };
 
 exports.DebuggerPanel = DebuggerPanel;
--- a/devtools/client/debugger/panel.js
+++ b/devtools/client/debugger/panel.js
@@ -88,16 +88,29 @@ DebuggerPanel.prototype = {
 
     return this._destroyer = this._controller.shutdownDebugger().then(() => {
       this.emit("destroyed");
     });
   },
 
   // DebuggerPanel API
 
+  getFrames() {
+    let framesController = this.panelWin.DebuggerController.StackFrames;
+    let thread = framesController.activeThread;
+    if (thread && thread.paused) {
+      return {
+        frames: thread.cachedFrames,
+        selected: framesController.currentFrameDepth,
+      };
+    }
+
+    return null;
+  },
+
   addBreakpoint: function (location) {
     const { actions } = this.panelWin;
     const { dispatch } = this._controller;
 
     return dispatch(actions.addBreakpoint(location));
   },
 
   removeBreakpoint: function (location) {
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -516,28 +516,22 @@ WebConsole.prototype = {
    */
   getDebuggerFrames: function WC_getDebuggerFrames()
   {
     let toolbox = gDevTools.getToolbox(this.target);
     if (!toolbox) {
       return null;
     }
     let panel = toolbox.getPanel("jsdebugger");
+
     if (!panel) {
       return null;
     }
-    let framesController = panel.panelWin.DebuggerController.StackFrames;
-    let thread = framesController.activeThread;
-    if (thread && thread.paused) {
-      return {
-        frames: thread.cachedFrames,
-        selected: framesController.currentFrameDepth,
-      };
-    }
-    return null;
+
+    return panel.getFrames();
   },
 
   /**
    * Retrieves the current selection from the Inspector, if such a selection
    * exists. This is used to pass the ID of the selected actor to the Web
    * Console server for the $0 helper.
    *
    * @return object|null