michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Bug 737803: Setting a breakpoint in a line without code should move michael@0: * the icon to the actual location. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; michael@0: michael@0: function test() { michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving; michael@0: michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gEditor = gDebugger.DebuggerView.editor; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: gBreakpoints = gDebugger.DebuggerController.Breakpoints; michael@0: gBreakpointsAdded = gBreakpoints._added; michael@0: gBreakpointsRemoving = gBreakpoints._removing; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); michael@0: gDebuggee.firstCall(); michael@0: }); michael@0: michael@0: function performTest() { michael@0: is(gBreakpointsAdded.size, 0, michael@0: "No breakpoints currently added."); michael@0: is(gBreakpointsRemoving.size, 0, michael@0: "No breakpoints currently being removed."); michael@0: is(gEditor.getBreakpoints().length, 0, michael@0: "No breakpoints currently shown in the editor."); michael@0: michael@0: gEditor.on("breakpointAdded", onEditorBreakpointAdd); michael@0: gPanel.addBreakpoint({ url: gSources.selectedValue, line: 4 }).then(onBreakpointAdd); michael@0: } michael@0: michael@0: let onBpDebuggerAdd = false; michael@0: let onBpEditorAdd = false; michael@0: michael@0: function onBreakpointAdd(aBreakpointClient) { michael@0: ok(aBreakpointClient, michael@0: "Breakpoint added, client received."); michael@0: is(aBreakpointClient.location.url, gSources.selectedValue, michael@0: "Breakpoint client url is the same."); michael@0: is(aBreakpointClient.location.line, 6, michael@0: "Breakpoint client line is new."); michael@0: michael@0: is(aBreakpointClient.requestedLocation.url, gSources.selectedValue, michael@0: "Requested location url is correct"); michael@0: is(aBreakpointClient.requestedLocation.line, 4, michael@0: "Requested location line is correct"); michael@0: michael@0: onBpDebuggerAdd = true; michael@0: maybeFinish(); michael@0: } michael@0: michael@0: function onEditorBreakpointAdd() { michael@0: gEditor.off("breakpointAdded", onEditorBreakpointAdd); michael@0: michael@0: is(gEditor.getBreakpoints().length, 1, michael@0: "There is only one breakpoint in the editor"); michael@0: michael@0: ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 4 }), michael@0: "There isn't any breakpoint added on an invalid line."); michael@0: ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 4 }), michael@0: "There isn't any breakpoint removed from an invalid line."); michael@0: michael@0: ok(gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }), michael@0: "There is a breakpoint added on the actual line."); michael@0: ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }), michael@0: "There isn't any breakpoint removed from the actual line."); michael@0: michael@0: gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }).then(aBreakpointClient => { michael@0: is(aBreakpointClient.location.url, gSources.selectedValue, michael@0: "Breakpoint client location url is correct."); michael@0: is(aBreakpointClient.location.line, 6, michael@0: "Breakpoint client location line is correct."); michael@0: michael@0: onBpEditorAdd = true; michael@0: maybeFinish(); michael@0: }); michael@0: } michael@0: michael@0: function maybeFinish() { michael@0: info("onBpDebuggerAdd: " + onBpDebuggerAdd); michael@0: info("onBpEditorAdd: " + onBpEditorAdd); michael@0: michael@0: if (onBpDebuggerAdd && onBpEditorAdd) { michael@0: resumeDebuggerThenCloseAndFinish(gPanel); michael@0: } michael@0: } michael@0: }