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 737803: Setting a breakpoint in a line without code should move |
michael@0 | 6 | * the icon to the actual location. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
michael@0 | 10 | |
michael@0 | 11 | function test() { |
michael@0 | 12 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 13 | let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving; |
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 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 21 | gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 22 | gBreakpoints = gDebugger.DebuggerController.Breakpoints; |
michael@0 | 23 | gBreakpointsAdded = gBreakpoints._added; |
michael@0 | 24 | gBreakpointsRemoving = gBreakpoints._removing; |
michael@0 | 25 | |
michael@0 | 26 | waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); |
michael@0 | 27 | gDebuggee.firstCall(); |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | function performTest() { |
michael@0 | 31 | is(gBreakpointsAdded.size, 0, |
michael@0 | 32 | "No breakpoints currently added."); |
michael@0 | 33 | is(gBreakpointsRemoving.size, 0, |
michael@0 | 34 | "No breakpoints currently being removed."); |
michael@0 | 35 | is(gEditor.getBreakpoints().length, 0, |
michael@0 | 36 | "No breakpoints currently shown in the editor."); |
michael@0 | 37 | |
michael@0 | 38 | gEditor.on("breakpointAdded", onEditorBreakpointAdd); |
michael@0 | 39 | gPanel.addBreakpoint({ url: gSources.selectedValue, line: 4 }).then(onBreakpointAdd); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | let onBpDebuggerAdd = false; |
michael@0 | 43 | let onBpEditorAdd = false; |
michael@0 | 44 | |
michael@0 | 45 | function onBreakpointAdd(aBreakpointClient) { |
michael@0 | 46 | ok(aBreakpointClient, |
michael@0 | 47 | "Breakpoint added, client received."); |
michael@0 | 48 | is(aBreakpointClient.location.url, gSources.selectedValue, |
michael@0 | 49 | "Breakpoint client url is the same."); |
michael@0 | 50 | is(aBreakpointClient.location.line, 6, |
michael@0 | 51 | "Breakpoint client line is new."); |
michael@0 | 52 | |
michael@0 | 53 | is(aBreakpointClient.requestedLocation.url, gSources.selectedValue, |
michael@0 | 54 | "Requested location url is correct"); |
michael@0 | 55 | is(aBreakpointClient.requestedLocation.line, 4, |
michael@0 | 56 | "Requested location line is correct"); |
michael@0 | 57 | |
michael@0 | 58 | onBpDebuggerAdd = true; |
michael@0 | 59 | maybeFinish(); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function onEditorBreakpointAdd() { |
michael@0 | 63 | gEditor.off("breakpointAdded", onEditorBreakpointAdd); |
michael@0 | 64 | |
michael@0 | 65 | is(gEditor.getBreakpoints().length, 1, |
michael@0 | 66 | "There is only one breakpoint in the editor"); |
michael@0 | 67 | |
michael@0 | 68 | ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 4 }), |
michael@0 | 69 | "There isn't any breakpoint added on an invalid line."); |
michael@0 | 70 | ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 4 }), |
michael@0 | 71 | "There isn't any breakpoint removed from an invalid line."); |
michael@0 | 72 | |
michael@0 | 73 | ok(gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }), |
michael@0 | 74 | "There is a breakpoint added on the actual line."); |
michael@0 | 75 | ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }), |
michael@0 | 76 | "There isn't any breakpoint removed from the actual line."); |
michael@0 | 77 | |
michael@0 | 78 | gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }).then(aBreakpointClient => { |
michael@0 | 79 | is(aBreakpointClient.location.url, gSources.selectedValue, |
michael@0 | 80 | "Breakpoint client location url is correct."); |
michael@0 | 81 | is(aBreakpointClient.location.line, 6, |
michael@0 | 82 | "Breakpoint client location line is correct."); |
michael@0 | 83 | |
michael@0 | 84 | onBpEditorAdd = true; |
michael@0 | 85 | maybeFinish(); |
michael@0 | 86 | }); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | function maybeFinish() { |
michael@0 | 90 | info("onBpDebuggerAdd: " + onBpDebuggerAdd); |
michael@0 | 91 | info("onBpEditorAdd: " + onBpEditorAdd); |
michael@0 | 92 | |
michael@0 | 93 | if (onBpDebuggerAdd && onBpEditorAdd) { |
michael@0 | 94 | resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 95 | } |
michael@0 | 96 | } |
michael@0 | 97 | } |