browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-03.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 * Tests that conditional breakpoint expressions survive disabled breakpoints.
michael@0 6 */
michael@0 7
michael@0 8 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
michael@0 9
michael@0 10 function test() {
michael@0 11 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 12 let gSources, gBreakpoints, gLocation;
michael@0 13
michael@0 14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
michael@0 15 gTab = aTab;
michael@0 16 gDebuggee = aDebuggee;
michael@0 17 gPanel = aPanel;
michael@0 18 gDebugger = gPanel.panelWin;
michael@0 19 gSources = gDebugger.DebuggerView.Sources;
michael@0 20 gBreakpoints = gDebugger.DebuggerController.Breakpoints;
michael@0 21
michael@0 22 // This test forces conditional breakpoints to be evaluated on the
michael@0 23 // client-side
michael@0 24 var client = gPanel.target.client;
michael@0 25 client.mainRoot.traits.conditionalBreakpoints = false;
michael@0 26
michael@0 27 gLocation = { url: gSources.selectedValue, line: 18 };
michael@0 28
michael@0 29 waitForSourceAndCaretAndScopes(gPanel, ".html", 17)
michael@0 30 .then(addBreakpoint)
michael@0 31 .then(setConditional)
michael@0 32 .then(() => {
michael@0 33 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
michael@0 34 toggleBreakpoint();
michael@0 35 return finished;
michael@0 36 })
michael@0 37 .then(() => {
michael@0 38 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
michael@0 39 toggleBreakpoint();
michael@0 40 return finished;
michael@0 41 })
michael@0 42 .then(testConditionalExpressionOnClient)
michael@0 43 .then(() => {
michael@0 44 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
michael@0 45 openConditionalPopup();
michael@0 46 return finished;
michael@0 47 })
michael@0 48 .then(testConditionalExpressionInPopup)
michael@0 49 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 50 .then(null, aError => {
michael@0 51 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 52 });
michael@0 53
michael@0 54 gDebuggee.ermahgerd();
michael@0 55 });
michael@0 56
michael@0 57 function addBreakpoint() {
michael@0 58 return gPanel.addBreakpoint(gLocation);
michael@0 59 }
michael@0 60
michael@0 61 function setConditional(aClient) {
michael@0 62 aClient.conditionalExpression = "hello";
michael@0 63 }
michael@0 64
michael@0 65 function toggleBreakpoint() {
michael@0 66 EventUtils.sendMouseEvent({ type: "click" },
michael@0 67 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"),
michael@0 68 gDebugger);
michael@0 69 }
michael@0 70
michael@0 71 function openConditionalPopup() {
michael@0 72 EventUtils.sendMouseEvent({ type: "click" },
michael@0 73 gDebugger.document.querySelector(".dbg-breakpoint"),
michael@0 74 gDebugger);
michael@0 75 }
michael@0 76
michael@0 77 function testConditionalExpressionOnClient() {
michael@0 78 return gBreakpoints._getAdded(gLocation).then(aClient => {
michael@0 79 is(aClient.conditionalExpression, "hello", "The expression is correct (1).");
michael@0 80 });
michael@0 81 }
michael@0 82
michael@0 83 function testConditionalExpressionInPopup() {
michael@0 84 let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox");
michael@0 85 is(textbox.value, "hello", "The expression is correct (2).")
michael@0 86 }
michael@0 87 }

mercurial