michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that conditional breakpoint expressions survive disabled breakpoints. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html"; michael@0: michael@0: function test() { michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gSources, gBreakpoints, gLocation; michael@0: michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: gBreakpoints = gDebugger.DebuggerController.Breakpoints; michael@0: michael@0: // This test forces conditional breakpoints to be evaluated on the michael@0: // client-side michael@0: var client = gPanel.target.client; michael@0: client.mainRoot.traits.conditionalBreakpoints = false; michael@0: michael@0: gLocation = { url: gSources.selectedValue, line: 18 }; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 17) michael@0: .then(addBreakpoint) michael@0: .then(setConditional) michael@0: .then(() => { michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); michael@0: toggleBreakpoint(); michael@0: return finished; michael@0: }) michael@0: .then(() => { michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); michael@0: toggleBreakpoint(); michael@0: return finished; michael@0: }) michael@0: .then(testConditionalExpressionOnClient) michael@0: .then(() => { michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); michael@0: openConditionalPopup(); michael@0: return finished; michael@0: }) michael@0: .then(testConditionalExpressionInPopup) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: michael@0: gDebuggee.ermahgerd(); michael@0: }); michael@0: michael@0: function addBreakpoint() { michael@0: return gPanel.addBreakpoint(gLocation); michael@0: } michael@0: michael@0: function setConditional(aClient) { michael@0: aClient.conditionalExpression = "hello"; michael@0: } michael@0: michael@0: function toggleBreakpoint() { michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), michael@0: gDebugger); michael@0: } michael@0: michael@0: function openConditionalPopup() { michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebugger.document.querySelector(".dbg-breakpoint"), michael@0: gDebugger); michael@0: } michael@0: michael@0: function testConditionalExpressionOnClient() { michael@0: return gBreakpoints._getAdded(gLocation).then(aClient => { michael@0: is(aClient.conditionalExpression, "hello", "The expression is correct (1)."); michael@0: }); michael@0: } michael@0: michael@0: function testConditionalExpressionInPopup() { michael@0: let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox"); michael@0: is(textbox.value, "hello", "The expression is correct (2).") michael@0: } michael@0: }