Bug 974072 - Only restore breakpoints if there are breakpoints in the debugger server's breakpoint store; r=past

This commit is contained in:
Nick Fitzgerald 2014-02-18 14:35:50 -08:00
parent ac3c1e3b02
commit 164c79ce0c

View File

@ -20,6 +20,8 @@ let OBJECT_PREVIEW_MAX_ITEMS = 10;
* as after a refresh). * as after a refresh).
*/ */
function BreakpointStore() { function BreakpointStore() {
this._size = 0;
// If we have a whole-line breakpoint set at LINE in URL, then // If we have a whole-line breakpoint set at LINE in URL, then
// //
// this._wholeLineBreakpoints[URL][LINE] // this._wholeLineBreakpoints[URL][LINE]
@ -44,6 +46,8 @@ function BreakpointStore() {
} }
BreakpointStore.prototype = { BreakpointStore.prototype = {
_size: null,
get size() { return this._size; },
/** /**
* Add a breakpoint to the breakpoint store. * Add a breakpoint to the breakpoint store.
@ -75,6 +79,8 @@ BreakpointStore.prototype = {
} }
this._wholeLineBreakpoints[url][line] = aBreakpoint; this._wholeLineBreakpoints[url][line] = aBreakpoint;
} }
this._size++;
}, },
/** /**
@ -91,23 +97,29 @@ BreakpointStore.prototype = {
if (column != null) { if (column != null) {
if (this._breakpoints[url]) { if (this._breakpoints[url]) {
if (this._breakpoints[url][line]) { if (this._breakpoints[url][line]) {
delete this._breakpoints[url][line][column]; if (this._breakpoints[url][line][column]) {
delete this._breakpoints[url][line][column];
this._size--;
// If this was the last breakpoint on this line, delete the line from // If this was the last breakpoint on this line, delete the line from
// `this._breakpoints[url]` as well. Otherwise `_iterLines` will yield // `this._breakpoints[url]` as well. Otherwise `_iterLines` will yield
// this line even though we no longer have breakpoints on // this line even though we no longer have breakpoints on
// it. Furthermore, we use Object.keys() instead of just checking // it. Furthermore, we use Object.keys() instead of just checking
// `this._breakpoints[url].length` directly, because deleting // `this._breakpoints[url].length` directly, because deleting
// properties from sparse arrays doesn't update the `length` property // properties from sparse arrays doesn't update the `length` property
// like adding them does. // like adding them does.
if (Object.keys(this._breakpoints[url][line]).length === 0) { if (Object.keys(this._breakpoints[url][line]).length === 0) {
delete this._breakpoints[url][line]; delete this._breakpoints[url][line];
}
} }
} }
} }
} else { } else {
if (this._wholeLineBreakpoints[url]) { if (this._wholeLineBreakpoints[url]) {
delete this._wholeLineBreakpoints[url][line]; if (this._wholeLineBreakpoints[url][line]) {
delete this._wholeLineBreakpoints[url][line];
this._size--;
}
} }
} }
}, },
@ -2220,6 +2232,10 @@ ThreadActor.prototype = {
* Restore any pre-existing breakpoints to the scripts that we have access to. * Restore any pre-existing breakpoints to the scripts that we have access to.
*/ */
_restoreBreakpoints: function () { _restoreBreakpoints: function () {
if (this.breakpointStore.size === 0) {
return;
}
for (let s of this.dbg.findScripts()) { for (let s of this.dbg.findScripts()) {
this._addScript(s); this._addScript(s);
} }