browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-04.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Make sure that conditional breakpoints with undefined expressions
michael@0 6 * are stored as plain breakpoints when re-enabling them.
michael@0 7 */
michael@0 8
michael@0 9 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
michael@0 10
michael@0 11 function test() {
michael@0 12 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 13 let gSources, gBreakpoints, gLocation;
michael@0 14
michael@0 15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 16 gTab = aTab;
michael@0 17 gDebuggee = aDebuggee;
michael@0 18 gPanel = aPanel;
michael@0 19 gDebugger = gPanel.panelWin;
michael@0 20 gSources = gDebugger.DebuggerView.Sources;
michael@0 21 gBreakpoints = gDebugger.DebuggerController.Breakpoints;
michael@0 22
michael@0 23 // This test forces conditional breakpoints to be evaluated on the
michael@0 24 // client-side
michael@0 25 var client = gPanel.target.client;
michael@0 26 client.mainRoot.traits.conditionalBreakpoints = false;
michael@0 27
michael@0 28 gLocation = { url: gSources.selectedValue, line: 18 };
michael@0 29
michael@0 30 waitForSourceAndCaretAndScopes(gPanel, ".html", 17)
michael@0 31 .then(addBreakpoint)
michael@0 32 .then(setDummyConditional)
michael@0 33 .then(() => {
michael@0 34 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
michael@0 35 toggleBreakpoint();
michael@0 36 return finished;
michael@0 37 })
michael@0 38 .then(() => {
michael@0 39 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
michael@0 40 toggleBreakpoint();
michael@0 41 return finished;
michael@0 42 })
michael@0 43 .then(testConditionalExpressionOnClient)
michael@0 44 .then(() => {
michael@0 45 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
michael@0 46 openConditionalPopup();
michael@0 47 finished.then(() => ok(false, "The popup shouldn't have opened."));
michael@0 48 return waitForTime(1000);
michael@0 49 })
michael@0 50 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 51 .then(null, aError => {
michael@0 52 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 53 });
michael@0 54
michael@0 55 gDebuggee.ermahgerd();
michael@0 56 });
michael@0 57
michael@0 58 function addBreakpoint() {
michael@0 59 return gPanel.addBreakpoint(gLocation);
michael@0 60 }
michael@0 61
michael@0 62 function setDummyConditional(aClient) {
michael@0 63 // This happens when a conditional expression input popup is shown
michael@0 64 // but the user doesn't type anything into it.
michael@0 65 aClient.conditionalExpression = "";
michael@0 66 }
michael@0 67
michael@0 68 function toggleBreakpoint() {
michael@0 69 EventUtils.sendMouseEvent({ type: "click" },
michael@0 70 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"),
michael@0 71 gDebugger);
michael@0 72 }
michael@0 73
michael@0 74 function openConditionalPopup() {
michael@0 75 EventUtils.sendMouseEvent({ type: "click" },
michael@0 76 gDebugger.document.querySelector(".dbg-breakpoint"),
michael@0 77 gDebugger);
michael@0 78 }
michael@0 79
michael@0 80 function testConditionalExpressionOnClient() {
michael@0 81 return gBreakpoints._getAdded(gLocation).then(aClient => {
michael@0 82 if ("conditionalExpression" in aClient) {
michael@0 83 ok(false, "A conditional expression shouldn't have been set.");
michael@0 84 } else {
michael@0 85 ok(true, "The conditional expression wasn't set, as expected.");
michael@0 86 }
michael@0 87 });
michael@0 88 }
michael@0 89 }

mercurial