From 57c9528600d8bdc527dc67e96eed1293322121fb Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 15 Mar 2014 18:48:55 -0700 Subject: [PATCH] Bug 981258 - Set the breakpoints in browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js before executng the IIFE so that the IIFE's Debugger.Script can't be GC'd before the breakpoints are set; r=past --- ...-break-on-last-line-of-script-on-reload.js | 37 +++++++++++++------ ...-break-on-last-line-of-script-on-reload.js | 1 + toolkit/devtools/server/actors/script.js | 12 +++++- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/browser/devtools/debugger/test/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js b/browser/devtools/debugger/test/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js index d33d00cfc870..57881460dd09 100644 --- a/browser/devtools/debugger/test/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js @@ -23,15 +23,20 @@ function test() { Task.spawn(function* () { try { - yield ensureSourceIs(gPanel, CODE_URL, true); + // Refresh and hit the debugger statement before the location we want to + // set our breakpoints. We have to pause before the breakpoint locations + // so that GC doesn't get a chance to kick in and collect the IIFE's + // script, which would causes us to receive a 'noScript' error from the + // server when we try to set the breakpoints. + const [paused, ] = yield promise.all([ + waitForThreadEvents(gPanel, "paused"), + reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN), + ]); - // Pause and set our breakpoints. - yield doInterrupt(); + is(paused.why.type, "debuggerStatement"); + + // Set our breakpoints. const [bp1, bp2, bp3] = yield promise.all([ - setBreakpoint({ - url: CODE_URL, - line: 2 - }), setBreakpoint({ url: CODE_URL, line: 3 @@ -39,23 +44,31 @@ function test() { setBreakpoint({ url: CODE_URL, line: 4 + }), + setBreakpoint({ + url: CODE_URL, + line: 5 }) ]); - // Should hit the first breakpoint on reload. + // Refresh and hit the debugger statement again. yield promise.all([ reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN), - waitForCaretUpdated(gPanel, 2) + waitForCaretAndScopes(gPanel, 1) ]); - // And should hit the other breakpoints as we resume. + // And we should hit the breakpoints as we resume. yield promise.all([ doResume(), - waitForCaretUpdated(gPanel, 3) + waitForCaretAndScopes(gPanel, 3) ]); yield promise.all([ doResume(), - waitForCaretUpdated(gPanel, 4) + waitForCaretAndScopes(gPanel, 4) + ]); + yield promise.all([ + doResume(), + waitForCaretAndScopes(gPanel, 5) ]); // Clean up the breakpoints. diff --git a/browser/devtools/debugger/test/code_breakpoints-break-on-last-line-of-script-on-reload.js b/browser/devtools/debugger/test/code_breakpoints-break-on-last-line-of-script-on-reload.js index f2078e9c40b2..a8e8a79731c3 100644 --- a/browser/devtools/debugger/test/code_breakpoints-break-on-last-line-of-script-on-reload.js +++ b/browser/devtools/debugger/test/code_breakpoints-break-on-last-line-of-script-on-reload.js @@ -1,3 +1,4 @@ +debugger; var a = (function(){ var b = 9; console.log("x", b); diff --git a/toolkit/devtools/server/actors/script.js b/toolkit/devtools/server/actors/script.js index 3eb542a62a22..841d3d47eca8 100644 --- a/toolkit/devtools/server/actors/script.js +++ b/toolkit/devtools/server/actors/script.js @@ -1362,7 +1362,13 @@ ThreadActor.prototype = { if (line == null || line < 0 || this.dbg.findScripts({ url: url }).length == 0) { - return { error: "noScript" }; + return { + error: "noScript", + message: "Requested setting a breakpoint on " + + url + ":" + line + + (column != null ? ":" + column : "") + + " but there is no Debugger.Script at that location" + }; } let response = this._createAndStoreBreakpoint({ @@ -1450,6 +1456,10 @@ ThreadActor.prototype = { if (scripts.length == 0) { return { error: "noScript", + message: "Requested setting a breakpoint on " + + aLocation.url + ":" + aLocation.line + + (aLocation.column != null ? ":" + aLocation.column : "") + + " but there is no Debugger.Script at that location", actor: actor.actorID }; }