Bug 1497393 - replace onPauseChange with native threadClient event.
authorJason Laster <jlaster@mozilla.com>
Wed, 10 Apr 2019 13:52:54 +0000
changeset 468785 98f1b0d8ff4b89601746b9bf561139e7234718e7
parent 468784 205b23b72638bfa3ede3942b3ba035ddb59ce8dc
child 468786 c040df7c239c286d24bd261c2aee42459d360ac6
push id112755
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 22:06:41 +0000
treeherdermozilla-inbound@606f85641d0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1497393
milestone68.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 1497393 - replace onPauseChange with native threadClient event. Differential Revision: https://phabricator.services.mozilla.com/D26831
devtools/client/debugger/src/actions/pause/paused.js
devtools/client/debugger/src/actions/pause/resumed.js
devtools/client/debugger/src/actions/pause/tests/pause.spec.js
devtools/client/debugger/src/actions/tests/ast.spec.js
devtools/client/debugger/src/actions/tests/expressions.spec.js
devtools/client/debugger/src/actions/tests/helpers/threadClient.js
devtools/client/debugger/src/client/firefox/commands.js
devtools/client/inspector/inspector.js
--- a/devtools/client/debugger/src/actions/pause/paused.js
+++ b/devtools/client/debugger/src/actions/pause/paused.js
@@ -30,18 +30,16 @@ import type { ThunkArgs } from "../types
  * @memberof actions/pause
  * @static
  */
 export function paused(pauseInfo: Pause) {
   return async function({ dispatch, getState, client, sourceMaps }: ThunkArgs) {
     const { thread, frames, why, loadedObjects } = pauseInfo;
     const topFrame = frames.length > 0 ? frames[0] : null;
 
-    client.onPauseChange(thread, true);
-
     dispatch({
       type: "PAUSED",
       thread,
       why,
       frames,
       selectedFrameId: topFrame ? topFrame.id : undefined,
       loadedObjects: loadedObjects || []
     });
--- a/devtools/client/debugger/src/actions/pause/resumed.js
+++ b/devtools/client/debugger/src/actions/pause/resumed.js
@@ -19,18 +19,16 @@ import type { ResumedPacket } from "../.
  */
 export function resumed(packet: ResumedPacket) {
   return async ({ dispatch, client, getState }: ThunkArgs) => {
     const thread = packet.from;
     const why = getPauseReason(getState(), thread);
     const wasPausedInEval = inDebuggerEval(why);
     const wasStepping = isStepping(getState(), thread);
 
-    client.onPauseChange(thread, false);
-
     dispatch({ type: "RESUME", thread, wasStepping });
 
     const cx = getThreadContext(getState());
     if (!wasStepping && !wasPausedInEval && cx.thread == thread) {
       await dispatch(evaluateExpressions(cx));
     }
   };
 }
--- a/devtools/client/debugger/src/actions/pause/tests/pause.spec.js
+++ b/devtools/client/debugger/src/actions/pause/tests/pause.spec.js
@@ -65,18 +65,17 @@ const mockThreadClient = {
         case "foo-wasm/originalSource":
           return resolve({
             source: "fn fooBar() {}\nfn barZoo() { fooBar() }",
             contentType: "text/rust"
           });
       }
     });
   },
-  getBreakpointPositions: async () => ({}),
-  onPauseChange() {}
+  getBreakpointPositions: async () => ({})
 };
 
 const mockFrameId = "1";
 
 function createPauseInfo(
   frameLocation = { sourceId: "foo1", line: 2 },
   frameOpts = {}
 ) {
--- a/devtools/client/debugger/src/actions/tests/ast.spec.js
+++ b/devtools/client/debugger/src/actions/tests/ast.spec.js
@@ -30,18 +30,17 @@ const threadClient = {
   sourceContents: async ({ source }) => ({
     source: sourceTexts[source],
     contentType: "text/javascript"
   }),
   getFrameScopes: async () => {},
   evaluate: async expression => ({ result: evaluationResult[expression] }),
   evaluateExpressions: async expressions =>
     expressions.map(expression => ({ result: evaluationResult[expression] })),
-  getBreakpointPositions: async () => ({}),
-  onPauseChange() {}
+  getBreakpointPositions: async () => ({})
 };
 
 const sourceMaps = {
   getOriginalSourceText: async ({ id }) => ({
     id,
     text: sourceTexts[id],
     contentType: "text/javascript"
   }),
--- a/devtools/client/debugger/src/actions/tests/expressions.spec.js
+++ b/devtools/client/debugger/src/actions/tests/expressions.spec.js
@@ -41,18 +41,17 @@ const mockThreadClient = {
   autocomplete: () => {
     return new Promise(resolve => {
       resolve({
         from: "foo",
         matches: ["toLocaleString", "toSource", "toString", "toolbar", "top"],
         matchProp: "to"
       });
     });
-  },
-  onPauseChange() {}
+  }
 };
 
 describe("expressions", () => {
   it("should add an expression", async () => {
     const { dispatch, getState, cx } = createStore(mockThreadClient);
 
     await dispatch(actions.addExpression(cx, "foo"));
     expect(selectors.getExpressions(getState()).size).toBe(1);
--- a/devtools/client/debugger/src/actions/tests/helpers/threadClient.js
+++ b/devtools/client/debugger/src/actions/tests/helpers/threadClient.js
@@ -73,11 +73,10 @@ export const sourceThreadClient = {
 
       reject(`unknown source: ${source}`);
     });
   },
   setBreakpoint: async () => {},
   threadClient: async () => {},
   getFrameScopes: async () => {},
   evaluateExpressions: async () => {},
-  getBreakpointPositions: async () => ({}),
-  onPauseChange() {}
+  getBreakpointPositions: async () => ({})
 };
--- a/devtools/client/debugger/src/client/firefox/commands.js
+++ b/devtools/client/debugger/src/client/firefox/commands.js
@@ -298,20 +298,16 @@ function autocomplete(
 function navigate(url: string): Promise<*> {
   return tabTarget.navigateTo({ url });
 }
 
 function reload(): Promise<*> {
   return tabTarget.reload();
 }
 
-function onPauseChange(thread: string, paused: boolean) {
-  tabTarget.emit("pause-change", { thread, paused });
-}
-
 function getProperties(thread: string, grip: Grip): Promise<*> {
   const objClient = lookupThreadClient(thread).pauseGrip(grip);
 
   return objClient.getPrototypeAndProperties().then(resp => {
     const { ownProperties, safeGetterValues } = resp;
     for (const name in safeGetterValues) {
       const { enumerable, writable, getterValue } = safeGetterValues[name];
       ownProperties[name] = { enumerable, writable, value: getterValue };
@@ -503,17 +499,16 @@ const clientCommands = {
   setXHRBreakpoint,
   removeXHRBreakpoint,
   removeBreakpoint,
   evaluate,
   evaluateInFrame,
   evaluateExpressions,
   navigate,
   reload,
-  onPauseChange,
   getProperties,
   getFrameScopes,
   pauseOnExceptions,
   fetchSources,
   registerSourceActor,
   fetchWorkers,
   getMainThread,
   sendPacket,
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -130,16 +130,17 @@ function Inspector(toolbox) {
   this.onPanelWindowResize = this.onPanelWindowResize.bind(this);
   this.onShowBoxModelHighlighterForNode =
     this.onShowBoxModelHighlighterForNode.bind(this);
   this.onSidebarHidden = this.onSidebarHidden.bind(this);
   this.onSidebarResized = this.onSidebarResized.bind(this);
   this.onSidebarSelect = this.onSidebarSelect.bind(this);
   this.onSidebarShown = this.onSidebarShown.bind(this);
   this.onSidebarToggle = this.onSidebarToggle.bind(this);
+  this.handleThreadState = this.handleThreadState.bind(this);
 
   this._target.on("will-navigate", this._onBeforeNavigate);
 }
 
 Inspector.prototype = {
   /**
    * open is effectively an asynchronous constructor
    */
@@ -150,18 +151,18 @@ Inspector.prototype = {
     // When replaying, we need to listen to changes in the target's pause state.
     if (this._target.isReplayEnabled()) {
       let dbg = this._toolbox.getPanel("jsdebugger");
       if (!dbg) {
         dbg = await this._toolbox.loadTool("jsdebugger");
       }
       this._replayResumed = !dbg.isPaused();
 
-      this._onReplayPauseChange = this._onReplayPauseChange.bind(this);
-      this._target.on("pause-change", this._onReplayPauseChange);
+      this._target.threadClient.addListener("paused", this.handleThreadState);
+      this._target.threadClient.addListener("resumed", this.handleThreadState);
     }
 
     await Promise.all([
       this._getCssProperties(),
       this._getPageStyle(),
       this._getDefaultSelection(),
       this._getAccessibilityFront(),
       this._getChangesFront(),
@@ -1119,19 +1120,18 @@ Inspector.prototype = {
     this._pendingSelection = onNodeSelected;
     this._getDefaultNodeForSelection()
         .then(onNodeSelected, this._handleRejectionIfNotDestroyed);
   },
 
   /**
    * When replaying, reset the inspector whenever the target paused or unpauses.
    */
-  _onReplayPauseChange({ paused }) {
-    this._replayResumed = !paused;
-
+  handleThreadState(event) {
+    this._replayResumed = event != "paused";
     this.onNewRoot();
   },
 
   /**
    * Handler for "markuploaded" event fired on a new root mutation and after the markup
    * view is initialized. Expands the current selected node and restores the saved
    * highlighter state.
    */