From 472c449ff99540af911a9a443e2591212efd30bc Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 11 Mar 2014 09:42:49 -0700 Subject: [PATCH] Bug 981258 - Clean up breakpoints manually before finishing the browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js test; r=past --- ...-break-on-last-line-of-script-on-reload.js | 92 ++++++++++++------- 1 file changed, 60 insertions(+), 32 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 1b4e7d1719a..48856a8f56a 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 @@ -21,42 +21,59 @@ function test() { gEvents = gDebugger.EVENTS; Task.spawn(function* () { - yield waitForSourceShown(gPanel, CODE_URL); + try { - // Pause and set our breakpoints. - yield doInterrupt(); - yield promise.all([ - gPanel.addBreakpoint({ - url: CODE_URL, - line: 2 - }), - gPanel.addBreakpoint({ - url: CODE_URL, - line: 3 - }), - gPanel.addBreakpoint({ - url: CODE_URL, - line: 4 - }) - ]); + yield waitForSourceShown(gPanel, CODE_URL); - // Should hit the first breakpoint on reload. - yield promise.all([ - reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN), - waitForCaretUpdated(gPanel, 2) - ]); + // Pause and set our breakpoints. + yield doInterrupt(); + const [bp1, bp2, bp3] = yield promise.all([ + setBreakpoint({ + url: CODE_URL, + line: 2 + }), + setBreakpoint({ + url: CODE_URL, + line: 3 + }), + setBreakpoint({ + url: CODE_URL, + line: 4 + }) + ]); - // And should hit the other breakpoints as we resume. - yield promise.all([ - doResume(), - waitForCaretUpdated(gPanel, 3) - ]); - yield promise.all([ - doResume(), - waitForCaretUpdated(gPanel, 4) - ]); + // Should hit the first breakpoint on reload. + yield promise.all([ + reloadActiveTab(gPanel, gEvents.SOURCE_SHOWN), + waitForCaretUpdated(gPanel, 2) + ]); - yield resumeDebuggerThenCloseAndFinish(gPanel); + // And should hit the other breakpoints as we resume. + yield promise.all([ + doResume(), + waitForCaretUpdated(gPanel, 3) + ]); + yield promise.all([ + doResume(), + waitForCaretUpdated(gPanel, 4) + ]); + + // Clean up the breakpoints. + yield promise.all([ + rdpInvoke(bp1, bp1.remove), + rdpInvoke(bp2, bp1.remove), + rdpInvoke(bp3, bp1.remove), + ]); + + yield resumeDebuggerThenCloseAndFinish(gPanel); + + } catch (e) { + DevToolsUtils.reportException( + "browser_dbg_breakpoints-break-on-last-line-of-script-on-reload.js", + e + ); + ok(false); + } }); }); @@ -76,4 +93,15 @@ function test() { function doInterrupt() { return rdpInvoke(gThreadClient, gThreadClient.interrupt); } + + function setBreakpoint(location) { + let deferred = promise.defer(); + gThreadClient.setBreakpoint(location, ({ error, message }, bpClient) => { + if (error) { + deferred.reject(error + ": " + message); + } + deferred.resolve(bpClient); + }); + return deferred.promise; + } }