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