Bug 1300036 - Update the state correctly on the client side when the server reports a conflict on resume. r=ejpbruel, a=ritu
☠☠ backed out by ab97d0cfa0a3 ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 05 Sep 2016 10:42:05 -0700
changeset 350440 84899036528a2504b2da757c25f1d79bebf0c6b5
parent 350439 620464bdbdfff5eeea1eb2b1194934cecb879c54
child 350441 d62aa3e31e3fe83b2417ce1a0a4a5ac07cad484a
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersejpbruel, ritu
bugs1300036
milestone50.0
Bug 1300036 - Update the state correctly on the client side when the server reports a conflict on resume. r=ejpbruel, a=ritu MozReview-Commit-ID: IK6LXEGXan
devtools/server/actors/script.js
devtools/shared/client/main.js
--- a/devtools/server/actors/script.js
+++ b/devtools/server/actors/script.js
@@ -977,17 +977,18 @@ const ThreadActor = ActorClassWithSpec(t
   /**
    * Handle a protocol request to resume execution of the debuggee.
    */
   onResume: function (aRequest) {
     if (this._state !== "paused") {
       return {
         error: "wrongState",
         message: "Can't resume when debuggee isn't paused. Current state is '"
-          + this._state + "'"
+          + this._state + "'",
+        state: this._state
       };
     }
 
     // In case of multiple nested event loops (due to multiple debuggers open in
     // different tabs or multiple debugger clients connected to the same tab)
     // only allow resumption in a LIFO order.
     if (this._nestedEventLoops.size && this._nestedEventLoops.lastPausedUrl
         && (this._nestedEventLoops.lastPausedUrl !== this._parent.url
--- a/devtools/shared/client/main.js
+++ b/devtools/shared/client/main.js
@@ -139,17 +139,18 @@ function eventSource(aProto) {
 
 /**
  * Set of protocol messages that affect thread state, and the
  * state the actor is in after each message.
  */
 const ThreadStateTypes = {
   "paused": "paused",
   "resumed": "attached",
-  "detached": "detached"
+  "detached": "detached",
+  "running": "attached"
 };
 
 /**
  * Set of protocol messages that are sent by the server without a prior request
  * by the client.
  */
 const UnsolicitedNotifications = {
   "consoleAPICall": "consoleAPICall",
@@ -1729,34 +1730,42 @@ ThreadClient.prototype = {
     type: "resume",
     resumeLimit: args(0)
   }, {
     before: function (aPacket) {
       this._assertPaused("resume");
 
       // Put the client in a tentative "resuming" state so we can prevent
       // further requests that should only be sent in the paused state.
+      this._previousState = this._state;
       this._state = "resuming";
 
       if (this._pauseOnExceptions) {
         aPacket.pauseOnExceptions = this._pauseOnExceptions;
       }
       if (this._ignoreCaughtExceptions) {
         aPacket.ignoreCaughtExceptions = this._ignoreCaughtExceptions;
       }
       if (this._pauseOnDOMEvents) {
         aPacket.pauseOnDOMEvents = this._pauseOnDOMEvents;
       }
       return aPacket;
     },
     after: function (aResponse) {
-      if (aResponse.error) {
-        // There was an error resuming, back to paused state.
-        this._state = "paused";
+      if (aResponse.error && this._state == "resuming") {
+        // There was an error resuming, update the state to the new one
+        // reported by the server, if given (only on wrongState), otherwise
+        // reset back to the previous state.
+        if (aResponse.state) {
+          this._state = ThreadStateTypes[aResponse.state];
+        } else {
+          this._state = this._previousState;
+        }
       }
+      delete this._previousState;
       return aResponse;
     },
   }),
 
   /**
    * Reconfigure the thread actor.
    *
    * @param object aOptions