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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-actual-location2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     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 1008372: Setting a breakpoint in a line without code should move
     1.9 + * the icon to the actual location, and if a breakpoint already exists
    1.10 + * on the new location don't duplicate
    1.11 + */
    1.12 +
    1.13 +const TAB_URL = EXAMPLE_URL + "doc_breakpoint-move.html";
    1.14 +
    1.15 +function test() {
    1.16 +  let gTab, gDebuggee, gPanel, gDebugger;
    1.17 +  let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving;
    1.18 +
    1.19 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.20 +    gTab = aTab;
    1.21 +    gDebuggee = aDebuggee;
    1.22 +    gPanel = aPanel;
    1.23 +    gDebugger = gPanel.panelWin;
    1.24 +    gEditor = gDebugger.DebuggerView.editor;
    1.25 +    gSources = gDebugger.DebuggerView.Sources;
    1.26 +    gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    1.27 +    gBreakpointsAdded = gBreakpoints._added;
    1.28 +    gBreakpointsRemoving = gBreakpoints._removing;
    1.29 +
    1.30 +    waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest);
    1.31 +    gDebuggee.ermahgerd();
    1.32 +  });
    1.33 +
    1.34 +  function performTest() {
    1.35 +    is(gBreakpointsAdded.size, 0,
    1.36 +      "No breakpoints currently added.");
    1.37 +    is(gBreakpointsRemoving.size, 0,
    1.38 +      "No breakpoints currently being removed.");
    1.39 +    is(gEditor.getBreakpoints().length, 0,
    1.40 +      "No breakpoints currently shown in the editor.");
    1.41 +
    1.42 +    Task.spawn(function*() {
    1.43 +      let bpClient = yield gPanel.addBreakpoint({
    1.44 +        url: gSources.selectedValue,
    1.45 +        line: 19
    1.46 +      });
    1.47 +      yield gPanel.addBreakpoint({
    1.48 +        url: gSources.selectedValue,
    1.49 +        line: 20
    1.50 +      });
    1.51 +
    1.52 +      let movedBpClient = yield gPanel.addBreakpoint({
    1.53 +        url: gSources.selectedValue,
    1.54 +        line: 17
    1.55 +      });
    1.56 +      testMovedLocation(movedBpClient);
    1.57 +
    1.58 +      yield resumeAndTestBreakpoint(19);
    1.59 +
    1.60 +      yield gPanel.removeBreakpoint({
    1.61 +        url: gSources.selectedValue,
    1.62 +        line: 19
    1.63 +      });
    1.64 +
    1.65 +      yield resumeAndTestBreakpoint(20);
    1.66 +      yield doResume(gPanel);
    1.67 +
    1.68 +      executeSoon(() => gDebuggee.ermahgerd());
    1.69 +      yield waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
    1.70 +
    1.71 +      yield resumeAndTestBreakpoint(20);
    1.72 +      resumeDebuggerThenCloseAndFinish(gPanel);
    1.73 +    });
    1.74 +  }
    1.75 +
    1.76 +  function resumeAndTestBreakpoint(line) {
    1.77 +    return Task.spawn(function*() {
    1.78 +      let event = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES);
    1.79 +      doResume(gPanel);
    1.80 +      yield event;
    1.81 +      testBreakpoint(line);
    1.82 +    });
    1.83 +  };
    1.84 +
    1.85 +  function testBreakpoint(line) {
    1.86 +    let selectedBreakpoint = gSources._selectedBreakpointItem;
    1.87 +    ok(selectedBreakpoint,
    1.88 +       "There should be a selected breakpoint on line " + line);
    1.89 +    is(selectedBreakpoint.attachment.line, line,
    1.90 +       "The breakpoint on line " + line + " was not hit");
    1.91 +  }
    1.92 +
    1.93 +  function testMovedLocation(breakpointClient) {
    1.94 +    ok(breakpointClient,
    1.95 +      "Breakpoint added, client received.");
    1.96 +    is(breakpointClient.location.url, gSources.selectedValue,
    1.97 +      "Breakpoint client url is the same.");
    1.98 +    is(breakpointClient.location.line, 19,
    1.99 +      "Breakpoint client line is new.");
   1.100 +
   1.101 +    is(breakpointClient.requestedLocation.url, gSources.selectedValue,
   1.102 +      "Requested location url is correct");
   1.103 +    is(breakpointClient.requestedLocation.line, 17,
   1.104 +      "Requested location line is correct");
   1.105 +  }
   1.106 +}

mercurial