1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-actual-location.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Bug 737803: Setting a breakpoint in a line without code should move 1.9 + * the icon to the actual location. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.13 + 1.14 +function test() { 1.15 + let gTab, gDebuggee, gPanel, gDebugger; 1.16 + let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving; 1.17 + 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gEditor = gDebugger.DebuggerView.editor; 1.24 + gSources = gDebugger.DebuggerView.Sources; 1.25 + gBreakpoints = gDebugger.DebuggerController.Breakpoints; 1.26 + gBreakpointsAdded = gBreakpoints._added; 1.27 + gBreakpointsRemoving = gBreakpoints._removing; 1.28 + 1.29 + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); 1.30 + gDebuggee.firstCall(); 1.31 + }); 1.32 + 1.33 + function performTest() { 1.34 + is(gBreakpointsAdded.size, 0, 1.35 + "No breakpoints currently added."); 1.36 + is(gBreakpointsRemoving.size, 0, 1.37 + "No breakpoints currently being removed."); 1.38 + is(gEditor.getBreakpoints().length, 0, 1.39 + "No breakpoints currently shown in the editor."); 1.40 + 1.41 + gEditor.on("breakpointAdded", onEditorBreakpointAdd); 1.42 + gPanel.addBreakpoint({ url: gSources.selectedValue, line: 4 }).then(onBreakpointAdd); 1.43 + } 1.44 + 1.45 + let onBpDebuggerAdd = false; 1.46 + let onBpEditorAdd = false; 1.47 + 1.48 + function onBreakpointAdd(aBreakpointClient) { 1.49 + ok(aBreakpointClient, 1.50 + "Breakpoint added, client received."); 1.51 + is(aBreakpointClient.location.url, gSources.selectedValue, 1.52 + "Breakpoint client url is the same."); 1.53 + is(aBreakpointClient.location.line, 6, 1.54 + "Breakpoint client line is new."); 1.55 + 1.56 + is(aBreakpointClient.requestedLocation.url, gSources.selectedValue, 1.57 + "Requested location url is correct"); 1.58 + is(aBreakpointClient.requestedLocation.line, 4, 1.59 + "Requested location line is correct"); 1.60 + 1.61 + onBpDebuggerAdd = true; 1.62 + maybeFinish(); 1.63 + } 1.64 + 1.65 + function onEditorBreakpointAdd() { 1.66 + gEditor.off("breakpointAdded", onEditorBreakpointAdd); 1.67 + 1.68 + is(gEditor.getBreakpoints().length, 1, 1.69 + "There is only one breakpoint in the editor"); 1.70 + 1.71 + ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 4 }), 1.72 + "There isn't any breakpoint added on an invalid line."); 1.73 + ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 4 }), 1.74 + "There isn't any breakpoint removed from an invalid line."); 1.75 + 1.76 + ok(gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }), 1.77 + "There is a breakpoint added on the actual line."); 1.78 + ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }), 1.79 + "There isn't any breakpoint removed from the actual line."); 1.80 + 1.81 + gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }).then(aBreakpointClient => { 1.82 + is(aBreakpointClient.location.url, gSources.selectedValue, 1.83 + "Breakpoint client location url is correct."); 1.84 + is(aBreakpointClient.location.line, 6, 1.85 + "Breakpoint client location line is correct."); 1.86 + 1.87 + onBpEditorAdd = true; 1.88 + maybeFinish(); 1.89 + }); 1.90 + } 1.91 + 1.92 + function maybeFinish() { 1.93 + info("onBpDebuggerAdd: " + onBpDebuggerAdd); 1.94 + info("onBpEditorAdd: " + onBpEditorAdd); 1.95 + 1.96 + if (onBpDebuggerAdd && onBpEditorAdd) { 1.97 + resumeDebuggerThenCloseAndFinish(gPanel); 1.98 + } 1.99 + } 1.100 +}