1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_server-conditional-bp-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Make sure that conditional breakpoints with undefined expressions 1.9 + * are stored as plain breakpoints when re-enabling them (with 1.10 + * server-side support) 1.11 + */ 1.12 + 1.13 +const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html"; 1.14 + 1.15 +function test() { 1.16 + let gTab, gDebuggee, gPanel, gDebugger; 1.17 + let gSources, gBreakpoints, gLocation; 1.18 + 1.19 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.20 + gTab = aTab; 1.21 + gDebuggee = aDebuggee; 1.22 + gPanel = aPanel; 1.23 + gDebugger = gPanel.panelWin; 1.24 + gSources = gDebugger.DebuggerView.Sources; 1.25 + gBreakpoints = gDebugger.DebuggerController.Breakpoints; 1.26 + 1.27 + gLocation = { url: gSources.selectedValue, line: 18 }; 1.28 + 1.29 + waitForSourceAndCaretAndScopes(gPanel, ".html", 17) 1.30 + .then(addBreakpoint) 1.31 + .then(setDummyConditional) 1.32 + .then(() => { 1.33 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); 1.34 + toggleBreakpoint(); 1.35 + return finished; 1.36 + }) 1.37 + .then(() => { 1.38 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); 1.39 + toggleBreakpoint(); 1.40 + return finished; 1.41 + }) 1.42 + .then(testConditionalExpressionOnClient) 1.43 + .then(() => { 1.44 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); 1.45 + openConditionalPopup(); 1.46 + finished.then(() => ok(false, "The popup shouldn't have opened.")); 1.47 + return waitForTime(1000); 1.48 + }) 1.49 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.50 + .then(null, aError => { 1.51 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.52 + }); 1.53 + 1.54 + gDebuggee.ermahgerd(); 1.55 + }); 1.56 + 1.57 + function addBreakpoint() { 1.58 + return gPanel.addBreakpoint(gLocation); 1.59 + } 1.60 + 1.61 + function setDummyConditional(aClient) { 1.62 + // This happens when a conditional expression input popup is shown 1.63 + // but the user doesn't type anything into it. 1.64 + return gBreakpoints.updateCondition(aClient.location, ''); 1.65 + } 1.66 + 1.67 + function toggleBreakpoint() { 1.68 + EventUtils.sendMouseEvent({ type: "click" }, 1.69 + gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), 1.70 + gDebugger); 1.71 + } 1.72 + 1.73 + function openConditionalPopup() { 1.74 + EventUtils.sendMouseEvent({ type: "click" }, 1.75 + gDebugger.document.querySelector(".dbg-breakpoint"), 1.76 + gDebugger); 1.77 + } 1.78 + 1.79 + function testConditionalExpressionOnClient() { 1.80 + return gBreakpoints._getAdded(gLocation).then(aClient => { 1.81 + if ("condition" in aClient) { 1.82 + ok(false, "A conditional expression shouldn't have been set."); 1.83 + } else { 1.84 + ok(true, "The conditional expression wasn't set, as expected."); 1.85 + } 1.86 + }); 1.87 + } 1.88 +}