Bug 1122064 - add all scripts to ScriptStore, including all nested child scripts. r=fitzgen

This commit is contained in:
James Long 2015-01-21 17:41:00 +01:00
parent ce0edcc50a
commit 5b39b1ea41
3 changed files with 91 additions and 5 deletions

View File

@ -1976,14 +1976,14 @@ ThreadActor.prototype = {
// inside _addScript, we can accidentally set a breakpoint in a top level
// script as a "closest match" because we wouldn't have added the child
// scripts to the ScriptStore yet.
this.scripts.addScript(aScript);
this.scripts.addScripts(aScript.getChildScripts());
this.scripts.addScripts(this.dbg.findScripts({ source: aScript.source }));
this._addScript(aScript);
// |onNewScript| is only fired for top level scripts (AKA staticLevel == 0),
// so we have to make sure to call |_addScript| on every child script as
// well to restore breakpoints in those scripts.
// `onNewScript` is only fired for top-level scripts (AKA staticLevel == 0),
// but top-level scripts have the wrong `lineCount` sometimes (bug 979094),
// so iterate over the immediate children to activate breakpoints for now
// (TODO bug 1124258: don't do this when `lineCount` bug is fixed)
for (let s of aScript.getChildScripts()) {
this._addScript(s);
}

View File

@ -0,0 +1,85 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Bug 1122064 - make sure that scripts introduced via onNewScripts
* properly populate the `ScriptStore` with all there nested child
* scripts, so you can set breakpoints on deeply nested scripts
*/
var gDebuggee;
var gClient;
var gThreadClient;
var gCallback;
function run_test()
{
run_test_with_server(DebuggerServer, function () {
run_test_with_server(WorkerDebuggerServer, do_test_finished);
});
do_test_pending();
};
function run_test_with_server(aServer, aCallback)
{
gCallback = aCallback;
initTestDebuggerServer(aServer);
gDebuggee = addTestGlobal("test-breakpoints", aServer);
gClient = new DebuggerClient(aServer.connectPipe());
gClient.connect(function () {
attachTestTabAndResume(gClient,
"test-breakpoints",
function (aResponse, aTabClient, aThreadClient) {
gThreadClient = aThreadClient;
test();
});
});
}
const test = Task.async(function*() {
// Populate the `ScriptStore` so that we only test that the script
// is added through `onNewScript`
yield getSources(gThreadClient);
let packet = yield executeOnNextTickAndWaitForPause(evalCode, gClient);
let source = gThreadClient.source(packet.frame.where.source);
let location = {
line: gDebuggee.line0 + 8
};
let [res, bpClient] = yield setBreakpoint(source, location);
ok(!res.error);
yield resume(gThreadClient);
packet = yield waitForPause(gClient);
do_check_eq(packet.type, "paused");
do_check_eq(packet.why.type, "breakpoint");
do_check_eq(packet.why.actors[0], bpClient.actor);
do_check_eq(packet.frame.where.source.actor, source.actor);
do_check_eq(packet.frame.where.line, location.line);
yield resume(gThreadClient);
finishClient(gClient);
});
function evalCode() {
// Start a new script
Components.utils.evalInSandbox(
"var line0 = Error().lineNumber;\n(" + function() {
debugger;
var a = (function() {
return (function() {
return (function() {
return (function() {
return (function() {
var x = 10; // This line gets a breakpoint
return 1;
})();
})();
})();
})();
})();
} + ")()",
gDebuggee
);
}

View File

@ -121,6 +121,7 @@ reason = bug 820380
skip-if = true
reason = bug 1104838
[test_breakpoint-20.js]
[test_breakpoint-21.js]
[test_conditional_breakpoint-01.js]
[test_conditional_breakpoint-02.js]
[test_conditional_breakpoint-03.js]