Properly handle terminated scripts in the debugger (bug 814683). r=fitzgen
authorPanos Astithas <past@mozilla.com>
Tue, 15 Jul 2014 19:20:38 +0300
changeset 194238 c427c4b9b6f53b1a4d68c1a64099fc4973c727e0
parent 194237 0139b24156be0b0f65b0e4e922201871ed84b143
child 194239 f701765f120713e96997544c6fe315485a1c9248
push id7753
push userpastithas@mozilla.com
push dateWed, 16 Jul 2014 07:34:26 +0000
treeherderfx-team@c427c4b9b6f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs814683
milestone33.0a1
Properly handle terminated scripts in the debugger (bug 814683). r=fitzgen
browser/devtools/debugger/debugger-controller.js
toolkit/devtools/server/actors/script.js
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -855,21 +855,17 @@ StackFrames.prototype = {
       return promise.reject(new Error("No stack frame available."));
     }
 
     let deferred = promise.defer();
 
     this.activeThread.addOneTimeListener("paused", (aEvent, aPacket) => {
       let { type, frameFinished } = aPacket.why;
       if (type == "clientEvaluated") {
-        if (!("terminated" in frameFinished)) {
-          deferred.resolve(frameFinished);
-        } else {
-          deferred.reject(new Error("The execution was abruptly terminated."));
-        }
+        deferred.resolve(frameFinished);
       } else {
         deferred.reject(new Error("Active thread paused unexpectedly."));
       }
     });
 
     let meta = "meta" in aOptions ? aOptions.meta : FRAME_TYPE.PUBLIC_CLIENT_EVAL;
     this._currentFrameDescription = meta;
     this.activeThread.eval(frame.actor, aExpression);
@@ -970,20 +966,21 @@ StackFrames.prototype = {
     }
 
     // Evaluation causes the stack frames to be cleared and active thread to
     // pause, sending a 'clientEvaluated' packet and adding the frames again.
     let evaluationOptions = { depth: 0, meta: FRAME_TYPE.WATCH_EXPRESSIONS_EVAL };
     yield this.evaluate(watchExpressions, evaluationOptions);
     this._currentFrameDescription = FRAME_TYPE.NORMAL;
 
-    // If an error was thrown during the evaluation of the watch expressions,
-    // then at least one expression evaluation could not be performed. So
-    // remove the most recent watch expression and try again.
-    if (this._currentEvaluation.throw) {
+    // If an error was thrown during the evaluation of the watch expressions
+    // or the evaluation was terminated from the slow script dialog, then at
+    // least one expression evaluation could not be performed. So remove the
+    // most recent watch expression and try again.
+    if (this._currentEvaluation.throw || this._currentEvaluation.terminated) {
       DebuggerView.WatchExpressions.removeAt(0);
       yield DebuggerController.StackFrames.syncWatchExpressions();
     }
   }),
 
   /**
    * Adds the watch expressions evaluation results to a scope in the view.
    *
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -2046,24 +2046,24 @@ ThreadActor.prototype = {
   },
 
   /**
    * Return a protocol completion value representing the given
    * Debugger-provided completion value.
    */
   createProtocolCompletionValue: function (aCompletion) {
     let protoValue = {};
-    if ("return" in aCompletion) {
+    if (aCompletion == null) {
+      protoValue.terminated = true;
+    } else if ("return" in aCompletion) {
       protoValue.return = this.createValueGrip(aCompletion.return);
-    } else if ("yield" in aCompletion) {
-      protoValue.return = this.createValueGrip(aCompletion.yield);
     } else if ("throw" in aCompletion) {
       protoValue.throw = this.createValueGrip(aCompletion.throw);
     } else {
-      protoValue.terminated = true;
+      protoValue.return = this.createValueGrip(aCompletion.yield);
     }
     return protoValue;
   },
 
   /**
    * Create a grip for the given debuggee object.
    *
    * @param aValue Debugger.Object