Bug 1494796 - get rid of ThreadClient specifics in DebuggerClient, interrupt method; r=jdescottes
authoryulia <ystartsev@mozilla.com>
Fri, 14 Jun 2019 04:23:57 +0000
changeset 478966 3c1c8393c6e81652ae0834cb6cd0379509e9d5a9
parent 478965 2a4f4639567ad479cd211dbe16159db2b4a830bf
child 478967 9732099eeb5693bcffc0e0ec870bb47c5d7fefec
push id88004
push userystartsev@mozilla.com
push dateFri, 14 Jun 2019 22:34:23 +0000
treeherderautoland@ae4f5a5b9feb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1494796
milestone69.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 1494796 - get rid of ThreadClient specifics in DebuggerClient, interrupt method; r=jdescottes Differential Revision: https://phabricator.services.mozilla.com/D32847
devtools/server/actors/thread.js
devtools/server/tests/unit/test_nesting-03.js
devtools/shared/specs/thread.js
--- a/devtools/server/actors/thread.js
+++ b/devtools/server/actors/thread.js
@@ -548,17 +548,17 @@ const ThreadActor = ActorClassWithSpec(t
       packet.frame.where = {
         actor: sourceActor.actorID,
         line: line,
         column: column,
       };
       const pkt = onPacket(packet);
 
       this._priorPause = pkt;
-      this.conn.send(pkt);
+      this.conn.sendActorEvent(this.actorID, "paused", pkt);
     } catch (error) {
       reportError(error);
       this.conn.send({
         error: "unknownError",
         message: error.message + "\n" + error.stack,
       });
       return undefined;
     }
@@ -1146,41 +1146,40 @@ const ThreadActor = ActorClassWithSpec(t
     for (const bpActor of this.breakpointActorMap.findActors()) {
       bpActor.removeScripts();
     }
   },
 
   /**
    * Handle a protocol request to pause the debuggee.
    */
-  onInterrupt: function(request) {
+  onInterrupt: function({when}) {
     if (this.state == "exited") {
       return { type: "exited" };
     } else if (this.state == "paused") {
       // TODO: return the actual reason for the existing pause.
-      return { type: "paused", why: { type: "alreadyPaused" } };
+      this.conn.sendActorEvent(this.actorID, "paused", { why: { type: "alreadyPaused" }});
+      return {};
     } else if (this.state != "running") {
       return { error: "wrongState",
                message: "Received interrupt request in " + this.state +
                         " state." };
     }
-
     try {
       // If execution should pause just before the next JavaScript bytecode is
       // executed, just set an onEnterFrame handler.
-      if (request.when == "onNext" && !this.dbg.replaying) {
+      if (when == "onNext" && !this.dbg.replaying) {
         const onEnterFrame = (frame) => {
-          return this._pauseAndRespond(frame, { type: "interrupted", onNext: true });
+          this._pauseAndRespond(frame, { type: "interrupted", onNext: true });
         };
         this.dbg.onEnterFrame = onEnterFrame;
 
         this.conn.sendActorEvent(this.actorID, "willInterrupt");
         return {};
       }
-
       if (this.dbg.replaying) {
         this.dbg.replayPause();
       }
 
       // If execution should pause immediately, just put ourselves in the paused
       // state.
       const packet = this._paused();
       if (!packet) {
@@ -1189,17 +1188,18 @@ const ThreadActor = ActorClassWithSpec(t
       // onNext is set while replaying so that the client will treat us as paused
       // at a breakpoint. When replaying we may need to pause and interact with
       // the server even if there are no frames on the stack.
       packet.why = { type: "interrupted", onNext: this.dbg.replaying };
 
       // Send the response to the interrupt request now (rather than
       // returning it), because we're going to start a nested event loop
       // here.
-      this.conn.send(packet);
+      this.conn.send({from: this.actorID, type: "interrupt"});
+      this.conn.sendActorEvent(this.actorID, "paused", packet);
 
       // Start a nested event loop.
       this._pushThreadPause();
 
       // We already sent a response to this request, don't send one
       // now.
       return null;
     } catch (e) {
--- a/devtools/server/tests/unit/test_nesting-03.js
+++ b/devtools/server/tests/unit/test_nesting-03.js
@@ -35,22 +35,22 @@ function start_second_connection() {
                      });
   });
 }
 
 async function test_nesting() {
   try {
     await gThreadClient1.resume();
   } catch (e) {
-    Assert.equal(e.error, "wrongOrder");
+    Assert.ok(e.includes("wrongOrder"));
   }
   try {
     await gThreadClient2.resume();
   } catch (e) {
-    Assert.ok(!e.error);
+    Assert.ok(!e);
   }
 
   gThreadClient1.resume().then(response => {
     Assert.ok(!response.error);
 
     gClient1.close(() => finishClient(gClient2));
   });
 }
--- a/devtools/shared/specs/thread.js
+++ b/devtools/shared/specs/thread.js
@@ -67,17 +67,16 @@ const threadSpec = generateActorSpec({
         count: Arg(1, "number"),
       },
       response: RetVal("json"),
     },
     interrupt: {
       request: {
         when: Arg(0, "json"),
       },
-      response: RetVal("nullable:json"),
     },
     sources: {
       response: RetVal("array:json"),
     },
     skipBreakpoints: {
       request: {
         skip: Arg(0, "json"),
       },