Properly handle terminated scripts in the debugger (
bug 814683). r=fitzgen
--- 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