1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 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. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html"; 1.13 + 1.14 +function test() { 1.15 + let gTab, gDebuggee, gPanel, gDebugger; 1.16 + let gSources, gBreakpoints, gLocation; 1.17 + 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gSources = gDebugger.DebuggerView.Sources; 1.24 + gBreakpoints = gDebugger.DebuggerController.Breakpoints; 1.25 + 1.26 + // This test forces conditional breakpoints to be evaluated on the 1.27 + // client-side 1.28 + var client = gPanel.target.client; 1.29 + client.mainRoot.traits.conditionalBreakpoints = false; 1.30 + 1.31 + gLocation = { url: gSources.selectedValue, line: 18 }; 1.32 + 1.33 + waitForSourceAndCaretAndScopes(gPanel, ".html", 17) 1.34 + .then(addBreakpoint) 1.35 + .then(setDummyConditional) 1.36 + .then(() => { 1.37 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); 1.38 + toggleBreakpoint(); 1.39 + return finished; 1.40 + }) 1.41 + .then(() => { 1.42 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); 1.43 + toggleBreakpoint(); 1.44 + return finished; 1.45 + }) 1.46 + .then(testConditionalExpressionOnClient) 1.47 + .then(() => { 1.48 + let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); 1.49 + openConditionalPopup(); 1.50 + finished.then(() => ok(false, "The popup shouldn't have opened.")); 1.51 + return waitForTime(1000); 1.52 + }) 1.53 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.54 + .then(null, aError => { 1.55 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.56 + }); 1.57 + 1.58 + gDebuggee.ermahgerd(); 1.59 + }); 1.60 + 1.61 + function addBreakpoint() { 1.62 + return gPanel.addBreakpoint(gLocation); 1.63 + } 1.64 + 1.65 + function setDummyConditional(aClient) { 1.66 + // This happens when a conditional expression input popup is shown 1.67 + // but the user doesn't type anything into it. 1.68 + aClient.conditionalExpression = ""; 1.69 + } 1.70 + 1.71 + function toggleBreakpoint() { 1.72 + EventUtils.sendMouseEvent({ type: "click" }, 1.73 + gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), 1.74 + gDebugger); 1.75 + } 1.76 + 1.77 + function openConditionalPopup() { 1.78 + EventUtils.sendMouseEvent({ type: "click" }, 1.79 + gDebugger.document.querySelector(".dbg-breakpoint"), 1.80 + gDebugger); 1.81 + } 1.82 + 1.83 + function testConditionalExpressionOnClient() { 1.84 + return gBreakpoints._getAdded(gLocation).then(aClient => { 1.85 + if ("conditionalExpression" in aClient) { 1.86 + ok(false, "A conditional expression shouldn't have been set."); 1.87 + } else { 1.88 + ok(true, "The conditional expression wasn't set, as expected."); 1.89 + } 1.90 + }); 1.91 + } 1.92 +}