Bug 877686 - Add UI to toggle the blackboxing of specific sources; r=vporof

This commit is contained in:
Nick Fitzgerald
2013-07-23 10:15:10 -07:00
parent b33293b92c
commit c55ba941c4
19 changed files with 620 additions and 47 deletions

View File

@@ -423,6 +423,7 @@ function StackFrames() {
this._onResumed = this._onResumed.bind(this);
this._onFrames = this._onFrames.bind(this);
this._onFramesCleared = this._onFramesCleared.bind(this);
this._onBlackBoxChange = this._onBlackBoxChange.bind(this);
this._afterFramesCleared = this._afterFramesCleared.bind(this);
this.evaluate = this.evaluate.bind(this);
}
@@ -447,6 +448,7 @@ StackFrames.prototype = {
this.activeThread.addListener("resumed", this._onResumed);
this.activeThread.addListener("framesadded", this._onFrames);
this.activeThread.addListener("framescleared", this._onFramesCleared);
window.addEventListener("Debugger:BlackBoxChange", this._onBlackBoxChange, false);
this._handleTabNavigation();
},
@@ -462,6 +464,7 @@ StackFrames.prototype = {
this.activeThread.removeListener("resumed", this._onResumed);
this.activeThread.removeListener("framesadded", this._onFrames);
this.activeThread.removeListener("framescleared", this._onFramesCleared);
window.removeEventListener("Debugger:BlackBoxChange", this._onBlackBoxChange, false);
},
/**
@@ -594,12 +597,22 @@ StackFrames.prototype = {
// Make sure all the previous stackframes are removed before re-adding them.
DebuggerView.StackFrames.empty();
let previousBlackBoxed = null;
for (let frame of this.activeThread.cachedFrames) {
let { depth, where: { url, line } } = frame;
let { depth, where: { url, line }, isBlackBoxed } = frame;
let frameLocation = NetworkHelper.convertToUnicode(unescape(url));
let frameTitle = StackFrameUtils.getFrameTitle(frame);
DebuggerView.StackFrames.addFrame(frameTitle, frameLocation, line, depth);
if (isBlackBoxed) {
if (previousBlackBoxed == url) {
continue;
}
previousBlackBoxed = url;
} else {
previousBlackBoxed = null;
}
DebuggerView.StackFrames.addFrame(frameTitle, frameLocation, line, depth, isBlackBoxed);
}
if (this.currentFrame == null) {
DebuggerView.StackFrames.selectedDepth = 0;
@@ -626,6 +639,18 @@ StackFrames.prototype = {
window.setTimeout(this._afterFramesCleared, FRAME_STEP_CLEAR_DELAY);
},
/**
* Handler for the debugger's BlackBoxChange notification.
*/
_onBlackBoxChange: function() {
if (this.activeThread.state == "paused") {
// We have to clear out the existing frames and refetch them to get their
// updated black boxed status.
this.activeThread._clearFrames();
this.activeThread.fillFrames(CALL_STACK_PAGE_SIZE);
}
},
/**
* Called soon after the thread client's framescleared notification.
*/
@@ -1000,6 +1025,27 @@ SourceScripts.prototype = {
window.dispatchEvent(document, "Debugger:AfterSourcesAdded");
},
/**
* Set the black boxed status of the given source.
*
* @param Object aSource
* The source form.
* @param bool aBlackBoxFlag
* True to black box the source, false to un-black box it.
*/
blackBox: function(aSource, aBlackBoxFlag) {
const sourceClient = this.activeThread.source(aSource);
sourceClient[aBlackBoxFlag ? "blackBox" : "unblackBox"](function({ error, message }) {
if (error) {
let msg = "Could not toggle black boxing for "
+ aSource.url + ": " + message;
dumpn(msg);
return void Cu.reportError(msg);
}
window.dispatchEvent(document, "Debugger:BlackBoxChange", sourceClient);
});
},
/**
* Gets a specified source's text.
*