Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Tests that conditional breakpoint expressions survive disabled breakpoints.
6 */
8 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
10 function test() {
11 let gTab, gDebuggee, gPanel, gDebugger;
12 let gSources, gBreakpoints, gLocation;
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
15 gTab = aTab;
16 gDebuggee = aDebuggee;
17 gPanel = aPanel;
18 gDebugger = gPanel.panelWin;
19 gSources = gDebugger.DebuggerView.Sources;
20 gBreakpoints = gDebugger.DebuggerController.Breakpoints;
22 // This test forces conditional breakpoints to be evaluated on the
23 // client-side
24 var client = gPanel.target.client;
25 client.mainRoot.traits.conditionalBreakpoints = false;
27 gLocation = { url: gSources.selectedValue, line: 18 };
29 waitForSourceAndCaretAndScopes(gPanel, ".html", 17)
30 .then(addBreakpoint)
31 .then(setConditional)
32 .then(() => {
33 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
34 toggleBreakpoint();
35 return finished;
36 })
37 .then(() => {
38 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
39 toggleBreakpoint();
40 return finished;
41 })
42 .then(testConditionalExpressionOnClient)
43 .then(() => {
44 let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
45 openConditionalPopup();
46 return finished;
47 })
48 .then(testConditionalExpressionInPopup)
49 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
50 .then(null, aError => {
51 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
52 });
54 gDebuggee.ermahgerd();
55 });
57 function addBreakpoint() {
58 return gPanel.addBreakpoint(gLocation);
59 }
61 function setConditional(aClient) {
62 aClient.conditionalExpression = "hello";
63 }
65 function toggleBreakpoint() {
66 EventUtils.sendMouseEvent({ type: "click" },
67 gDebugger.document.querySelector(".dbg-breakpoint-checkbox"),
68 gDebugger);
69 }
71 function openConditionalPopup() {
72 EventUtils.sendMouseEvent({ type: "click" },
73 gDebugger.document.querySelector(".dbg-breakpoint"),
74 gDebugger);
75 }
77 function testConditionalExpressionOnClient() {
78 return gBreakpoints._getAdded(gLocation).then(aClient => {
79 is(aClient.conditionalExpression, "hello", "The expression is correct (1).");
80 });
81 }
83 function testConditionalExpressionInPopup() {
84 let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox");
85 is(textbox.value, "hello", "The expression is correct (2).")
86 }
87 }