mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 04:35:33 +00:00
Bug 1122064 - add all scripts to ScriptStore, including all nested child scripts. r=fitzgen
This commit is contained in:
parent
ce0edcc50a
commit
5b39b1ea41
@ -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);
|
||||
}
|
||||
|
85
toolkit/devtools/server/tests/unit/test_breakpoint-21.js
Normal file
85
toolkit/devtools/server/tests/unit/test_breakpoint-21.js
Normal 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
|
||||
);
|
||||
}
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user