Commit 5f77a853 authored by yulia's avatar yulia
Browse files

Bug 1494796 - Removing threadClient specifics from DebuggerClient Special case...

Bug 1494796 - Removing threadClient specifics from DebuggerClient Special case resume; r=jdescottes,jlast

The resume case is much more complex than the other events, because we do an
unsafeSynchronize to send an unsolicited pause. In the old system, the resume response would have
been ignored, but that is no longer the case. With the new system, we do not want to send a response
to a resume action if it did not come from the UI. This also update the debugger panel code to
accept a resume.

Differential Revision: https://phabricator.services.mozilla.com/D32697

--HG--
extra : moz-landing-system : lando
parent 780b2f0e
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import { evaluateExpressions } from "../expressions";
import { inDebuggerEval } from "../../utils/pause";

import type { ThunkArgs } from "../types";
import type { ResumedPacket } from "../../client/firefox/types";
import type { ActorId } from "../../types";

/**
 * Debugger has just resumed
@@ -17,9 +17,8 @@ import type { ResumedPacket } from "../../client/firefox/types";
 * @memberof actions/pause
 * @static
 */
export function resumed(packet: ResumedPacket) {
export function resumed(thread: ActorId) {
  return async ({ dispatch, client, getState }: ThunkArgs) => {
    const thread = packet.from;
    const why = getPauseReason(getState(), thread);
    const wasPausedInEval = inDebuggerEval(why);
    const wasStepping = isStepping(getState(), thread);
+3 −5
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ const mockThreadClient = {
  },
  getBreakpointPositions: async () => ({}),
  getBreakableLines: async () => [],
  actorID: "threadActorID",
};

const mockFrameId = "1";
@@ -99,9 +100,6 @@ function createPauseInfo(
  };
}

function resumedPacket() {
  return { from: "FakeThread", type: "resumed" };
}
describe("pause", () => {
  describe("stepping", () => {
    it("should set and clear the command", async () => {
@@ -383,7 +381,7 @@ describe("pause", () => {

      const cx = selectors.getThreadContext(getState());
      dispatch(actions.stepIn(cx));
      await dispatch(actions.resumed(resumedPacket()));
      await dispatch(actions.resumed(mockThreadClient.actorID));
      expect(client.evaluateExpressions.mock.calls).toHaveLength(1);
    });

@@ -401,7 +399,7 @@ describe("pause", () => {
      client.evaluateExpressions.mockReturnValue(Promise.resolve(["YAY"]));
      await dispatch(actions.paused(mockPauseInfo));

      await dispatch(actions.resumed(resumedPacket()));
      await dispatch(actions.resumed(mockThreadClient.actorID));
      const expression = selectors.getExpression(getState(), "foo");
      expect(expression && expression.value).toEqual("YAY");
    });
+2 −3
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@

import type {
  SourcePacket,
  ResumedPacket,
  PausedPacket,
  ThreadClient,
  Actions,
@@ -74,7 +73,7 @@ async function paused(threadClient: ThreadClient, packet: PausedPacket) {
  }
}

function resumed(threadClient: ThreadClient, packet: ResumedPacket) {
function resumed(threadClient: ThreadClient) {
  // NOTE: the client suppresses resumed events while interrupted
  // to prevent unintentional behavior.
  // see [client docs](../README.md#interrupted) for more information.
@@ -83,7 +82,7 @@ function resumed(threadClient: ThreadClient, packet: ResumedPacket) {
    return;
  }

  actions.resumed(packet);
  actions.resumed(threadClient.actorID);
}

function newSource(threadClient: ThreadClient, { source }: SourcePacket) {
+2 −6
Original line number Diff line number Diff line
@@ -138,11 +138,6 @@ export type PausedPacket = {
  },
};

export type ResumedPacket = {
  from: ActorId,
  type: string,
};

/**
 * Response from the `getFrames` function call
 * @memberof firefox
@@ -187,7 +182,7 @@ export type TabPayload = {
 */
export type Actions = {
  paused: Pause => void,
  resumed: ResumedPacket => void,
  resumed: ActorId => void,
  newQueuedSources: (QueuedSourceData[]) => void,
  fetchEventListeners: () => void,
  updateWorkers: () => void,
@@ -369,6 +364,7 @@ export type ThreadClient = {
  getLastPausePacket: () => ?PausedPacket,
  _parent: TabClient,
  actor: ActorId,
  actorID: ActorId,
  request: (payload: Object) => Promise<*>,
  url: string,
  setActiveEventBreakpoints: (string[]) => void,
+1 −2
Original line number Diff line number Diff line
@@ -1346,8 +1346,7 @@ const browsingContextTargetPrototype = {
    // will-navigate
    const threadActor = this.threadActor;
    if (threadActor.state == "paused") {
      this.conn.send(
        threadActor.unsafeSynchronize(Promise.resolve(threadActor.onResume())));
      threadActor.unsafeSynchronize(Promise.resolve(threadActor.doResume()));
      threadActor.dbg.enabled = false;
    }
    threadActor.disableAllBreakpoints();
Loading