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.
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 | * Test that conditional breakpoints survive disabled breakpoints |
michael@0 | 6 | * (with server-side support) |
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 | gLocation = { url: gSources.selectedValue, line: 18 }; |
michael@0 | 24 | |
michael@0 | 25 | waitForSourceAndCaretAndScopes(gPanel, ".html", 17) |
michael@0 | 26 | .then(addBreakpoint) |
michael@0 | 27 | .then(setConditional) |
michael@0 | 28 | .then(() => { |
michael@0 | 29 | let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED); |
michael@0 | 30 | toggleBreakpoint(); |
michael@0 | 31 | return finished; |
michael@0 | 32 | }) |
michael@0 | 33 | .then(() => { |
michael@0 | 34 | let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED); |
michael@0 | 35 | toggleBreakpoint(); |
michael@0 | 36 | return finished; |
michael@0 | 37 | }) |
michael@0 | 38 | .then(testConditionalExpressionOnClient) |
michael@0 | 39 | .then(() => { |
michael@0 | 40 | let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING); |
michael@0 | 41 | openConditionalPopup(); |
michael@0 | 42 | return finished; |
michael@0 | 43 | }) |
michael@0 | 44 | .then(testConditionalExpressionInPopup) |
michael@0 | 45 | .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
michael@0 | 46 | .then(null, aError => { |
michael@0 | 47 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 48 | }); |
michael@0 | 49 | |
michael@0 | 50 | gDebuggee.ermahgerd(); |
michael@0 | 51 | }); |
michael@0 | 52 | |
michael@0 | 53 | function addBreakpoint() { |
michael@0 | 54 | return gPanel.addBreakpoint(gLocation); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function setConditional(aClient) { |
michael@0 | 58 | return gBreakpoints.updateCondition(aClient.location, "hello"); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function toggleBreakpoint() { |
michael@0 | 62 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 63 | gDebugger.document.querySelector(".dbg-breakpoint-checkbox"), |
michael@0 | 64 | gDebugger); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function openConditionalPopup() { |
michael@0 | 68 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 69 | gDebugger.document.querySelector(".dbg-breakpoint"), |
michael@0 | 70 | gDebugger); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function testConditionalExpressionOnClient() { |
michael@0 | 74 | return gBreakpoints._getAdded(gLocation).then(aClient => { |
michael@0 | 75 | is(aClient.condition, "hello", "The expression is correct (1)."); |
michael@0 | 76 | }); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function testConditionalExpressionInPopup() { |
michael@0 | 80 | let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox"); |
michael@0 | 81 | is(textbox.value, "hello", "The expression is correct (2).") |
michael@0 | 82 | } |
michael@0 | 83 | } |