browser/devtools/debugger/test/browser_dbg_breakpoints-actual-location2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 1008372: Setting a breakpoint in a line without code should move
michael@0 6 * the icon to the actual location, and if a breakpoint already exists
michael@0 7 * on the new location don't duplicate
michael@0 8 */
michael@0 9
michael@0 10 const TAB_URL = EXAMPLE_URL + "doc_breakpoint-move.html";
michael@0 11
michael@0 12 function test() {
michael@0 13 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 14 let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving;
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 gEditor = gDebugger.DebuggerView.editor;
michael@0 22 gSources = gDebugger.DebuggerView.Sources;
michael@0 23 gBreakpoints = gDebugger.DebuggerController.Breakpoints;
michael@0 24 gBreakpointsAdded = gBreakpoints._added;
michael@0 25 gBreakpointsRemoving = gBreakpoints._removing;
michael@0 26
michael@0 27 waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest);
michael@0 28 gDebuggee.ermahgerd();
michael@0 29 });
michael@0 30
michael@0 31 function performTest() {
michael@0 32 is(gBreakpointsAdded.size, 0,
michael@0 33 "No breakpoints currently added.");
michael@0 34 is(gBreakpointsRemoving.size, 0,
michael@0 35 "No breakpoints currently being removed.");
michael@0 36 is(gEditor.getBreakpoints().length, 0,
michael@0 37 "No breakpoints currently shown in the editor.");
michael@0 38
michael@0 39 Task.spawn(function*() {
michael@0 40 let bpClient = yield gPanel.addBreakpoint({
michael@0 41 url: gSources.selectedValue,
michael@0 42 line: 19
michael@0 43 });
michael@0 44 yield gPanel.addBreakpoint({
michael@0 45 url: gSources.selectedValue,
michael@0 46 line: 20
michael@0 47 });
michael@0 48
michael@0 49 let movedBpClient = yield gPanel.addBreakpoint({
michael@0 50 url: gSources.selectedValue,
michael@0 51 line: 17
michael@0 52 });
michael@0 53 testMovedLocation(movedBpClient);
michael@0 54
michael@0 55 yield resumeAndTestBreakpoint(19);
michael@0 56
michael@0 57 yield gPanel.removeBreakpoint({
michael@0 58 url: gSources.selectedValue,
michael@0 59 line: 19
michael@0 60 });
michael@0 61
michael@0 62 yield resumeAndTestBreakpoint(20);
michael@0 63 yield doResume(gPanel);
michael@0 64
michael@0 65 executeSoon(() => gDebuggee.ermahgerd());
michael@0 66 yield waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
michael@0 67
michael@0 68 yield resumeAndTestBreakpoint(20);
michael@0 69 resumeDebuggerThenCloseAndFinish(gPanel);
michael@0 70 });
michael@0 71 }
michael@0 72
michael@0 73 function resumeAndTestBreakpoint(line) {
michael@0 74 return Task.spawn(function*() {
michael@0 75 let event = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
michael@0 76 doResume(gPanel);
michael@0 77 yield event;
michael@0 78 testBreakpoint(line);
michael@0 79 });
michael@0 80 };
michael@0 81
michael@0 82 function testBreakpoint(line) {
michael@0 83 let selectedBreakpoint = gSources._selectedBreakpointItem;
michael@0 84 ok(selectedBreakpoint,
michael@0 85 "There should be a selected breakpoint on line " + line);
michael@0 86 is(selectedBreakpoint.attachment.line, line,
michael@0 87 "The breakpoint on line " + line + " was not hit");
michael@0 88 }
michael@0 89
michael@0 90 function testMovedLocation(breakpointClient) {
michael@0 91 ok(breakpointClient,
michael@0 92 "Breakpoint added, client received.");
michael@0 93 is(breakpointClient.location.url, gSources.selectedValue,
michael@0 94 "Breakpoint client url is the same.");
michael@0 95 is(breakpointClient.location.line, 19,
michael@0 96 "Breakpoint client line is new.");
michael@0 97
michael@0 98 is(breakpointClient.requestedLocation.url, gSources.selectedValue,
michael@0 99 "Requested location url is correct");
michael@0 100 is(breakpointClient.requestedLocation.line, 17,
michael@0 101 "Requested location line is correct");
michael@0 102 }
michael@0 103 }

mercurial