From f39b849fea99f0810865bc3d5208d3fbd627e2d6 Mon Sep 17 00:00:00 2001 From: Eddy Bruel Date: Thu, 8 Oct 2015 16:33:37 +0200 Subject: [PATCH] Bug 1205305 - Fix a race condition in browser_dbg_server-conditional-bp-02.js;r=jlong --- .../client/debugger/debugger-controller.js | 1 + .../browser_dbg_conditional-breakpoints-02.js | 2 ++ .../browser_dbg_server-conditional-bp-02.js | 2 ++ .../client/debugger/views/sources-view.js | 28 +++++++++++-------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/devtools/client/debugger/debugger-controller.js b/devtools/client/debugger/debugger-controller.js index b158fdf50a7c..fb0b4b974b38 100644 --- a/devtools/client/debugger/debugger-controller.js +++ b/devtools/client/debugger/debugger-controller.js @@ -42,6 +42,7 @@ const EVENTS = { // When a breakpoint has been added or removed on the debugger server. BREAKPOINT_ADDED: "Debugger:BreakpointAdded", BREAKPOINT_REMOVED: "Debugger:BreakpointRemoved", + BREAKPOINT_CLICKED: "Debugger:BreakpointClicked", // When a breakpoint has been shown or hidden in the source editor // or the pane. diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js b/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js index 2fff3b6dd53c..bb55f9ba04b6 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js @@ -195,8 +195,10 @@ function test() { } function clickOnBreakpoint(aIndex) { + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_CLICKED); EventUtils.sendMouseEvent({ type: "click" }, gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex], gDebugger); + return finished; } } diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js b/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js index 1fad10177dc4..6d7df4c29b31 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js @@ -184,8 +184,10 @@ function test() { } function clickOnBreakpoint(aIndex) { + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_CLICKED); EventUtils.sendMouseEvent({ type: "click" }, gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex], gDebugger); + return finished; } } diff --git a/devtools/client/debugger/views/sources-view.js b/devtools/client/debugger/views/sources-view.js index 3cd565717bb8..ac05af3b140f 100644 --- a/devtools/client/debugger/views/sources-view.js +++ b/devtools/client/debugger/views/sources-view.js @@ -466,9 +466,9 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { // If the breakpoint requires a new conditional expression, display // the panel to input the corresponding expression. if (aOptions.openPopup) { - this._openConditionalPopup(); + return this._openConditionalPopup(); } else { - this._hideConditionalPopup(); + return this._hideConditionalPopup(); } }, @@ -717,13 +717,13 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { // retrieve the current conditional epression. let breakpointPromise = this.Breakpoints._getAdded(attachment); if (breakpointPromise) { - breakpointPromise.then(aBreakpointClient => { + return breakpointPromise.then(aBreakpointClient => { let isConditionalBreakpoint = aBreakpointClient.hasCondition(); let condition = aBreakpointClient.getCondition(); - doOpen.call(this, isConditionalBreakpoint ? condition : "") + return doOpen.call(this, isConditionalBreakpoint ? condition : "") }); } else { - doOpen.call(this, "") + return doOpen.call(this, "") } function doOpen(aConditionalExpression) { @@ -1040,18 +1040,24 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, { let attachment = breakpointItem.attachment; // Check if this is an enabled conditional breakpoint. - let breakpointPromise = this.Breakpoints._getAdded(attachment); - if (breakpointPromise) { - breakpointPromise.then(aBreakpointClient => { - doHighlight.call(this, aBreakpointClient.hasCondition()); + let promise = this.Breakpoints._getAdded(attachment); + if (promise) { + promise = promise.then(aBreakpointClient => { + return doHighlight.call(this, aBreakpointClient.hasCondition()); }); } else { - doHighlight.call(this, false); + promise = Promise.resolve().then(() => { + return doHighlight.call(this, false) + }); } + promise.then(() => { + window.emit(EVENTS.BREAKPOINT_CLICKED); + }); + function doHighlight(aConditionalBreakpointFlag) { // Highlight the breakpoint in this pane and in the editor. - this.highlightBreakpoint(attachment, { + return this.highlightBreakpoint(attachment, { // Don't show the conditional expression popup if this is not a // conditional breakpoint, or the right mouse button was pressed (to // avoid clashing the popup with the context menu).