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 | * Bug 771452: Make sure that setting a breakpoint in an inline source doesn't |
michael@0 | 6 | * add it twice. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_inline-script.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
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 | |
michael@0 | 20 | addBreakpoint(); |
michael@0 | 21 | }); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function addBreakpoint() { |
michael@0 | 25 | waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => { |
michael@0 | 26 | is(gDebugger.gThreadClient.state, "paused", |
michael@0 | 27 | "The debugger statement was reached."); |
michael@0 | 28 | ok(isCaretPos(gPanel, 16), |
michael@0 | 29 | "The source editor caret position is incorrect (1)."); |
michael@0 | 30 | |
michael@0 | 31 | gPanel.addBreakpoint({ url: TAB_URL, line: 20 }).then(() => { |
michael@0 | 32 | testResume(); |
michael@0 | 33 | }); |
michael@0 | 34 | }); |
michael@0 | 35 | |
michael@0 | 36 | gDebuggee.runDebuggerStatement(); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function testResume() { |
michael@0 | 40 | is(gDebugger.gThreadClient.state, "paused", |
michael@0 | 41 | "The breakpoint wasn't hit yet."); |
michael@0 | 42 | |
michael@0 | 43 | gDebugger.gThreadClient.resume(() => { |
michael@0 | 44 | gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => { |
michael@0 | 45 | waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { |
michael@0 | 46 | is(aPacket.why.type, "breakpoint", |
michael@0 | 47 | "Execution has advanced to the next breakpoint."); |
michael@0 | 48 | isnot(aPacket.why.type, "debuggerStatement", |
michael@0 | 49 | "The breakpoint was hit before the debugger statement."); |
michael@0 | 50 | ok(isCaretPos(gPanel, 20), |
michael@0 | 51 | "The source editor caret position is incorrect (2)."); |
michael@0 | 52 | |
michael@0 | 53 | testBreakpointHit(); |
michael@0 | 54 | }); |
michael@0 | 55 | }); |
michael@0 | 56 | |
michael@0 | 57 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 58 | gDebuggee.document.querySelector("button"), |
michael@0 | 59 | gDebuggee); |
michael@0 | 60 | }); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function testBreakpointHit() { |
michael@0 | 64 | is(gDebugger.gThreadClient.state, "paused", |
michael@0 | 65 | "The breakpoint was hit."); |
michael@0 | 66 | |
michael@0 | 67 | gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => { |
michael@0 | 68 | waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { |
michael@0 | 69 | is(aPacket.why.type, "debuggerStatement", |
michael@0 | 70 | "Execution has advanced to the next line."); |
michael@0 | 71 | isnot(aPacket.why.type, "breakpoint", |
michael@0 | 72 | "No ghost breakpoint was hit."); |
michael@0 | 73 | ok(isCaretPos(gPanel, 20), |
michael@0 | 74 | "The source editor caret position is incorrect (3)."); |
michael@0 | 75 | |
michael@0 | 76 | resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 77 | }); |
michael@0 | 78 | }); |
michael@0 | 79 | |
michael@0 | 80 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 81 | gDebugger.document.getElementById("resume"), |
michael@0 | 82 | gDebugger); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | registerCleanupFunction(function() { |
michael@0 | 86 | gTab = null; |
michael@0 | 87 | gDebuggee = null; |
michael@0 | 88 | gPanel = null; |
michael@0 | 89 | gDebugger = null; |
michael@0 | 90 | }); |