browser/devtools/debugger/test/browser_dbg_breakpoints-actual-location.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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Bug 737803: Setting a breakpoint in a line without code should move
     6  * the icon to the actual location.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    11 function test() {
    12   let gTab, gDebuggee, gPanel, gDebugger;
    13   let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving;
    15   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    16     gTab = aTab;
    17     gDebuggee = aDebuggee;
    18     gPanel = aPanel;
    19     gDebugger = gPanel.panelWin;
    20     gEditor = gDebugger.DebuggerView.editor;
    21     gSources = gDebugger.DebuggerView.Sources;
    22     gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    23     gBreakpointsAdded = gBreakpoints._added;
    24     gBreakpointsRemoving = gBreakpoints._removing;
    26     waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest);
    27     gDebuggee.firstCall();
    28   });
    30   function performTest() {
    31     is(gBreakpointsAdded.size, 0,
    32       "No breakpoints currently added.");
    33     is(gBreakpointsRemoving.size, 0,
    34       "No breakpoints currently being removed.");
    35     is(gEditor.getBreakpoints().length, 0,
    36       "No breakpoints currently shown in the editor.");
    38     gEditor.on("breakpointAdded", onEditorBreakpointAdd);
    39     gPanel.addBreakpoint({ url: gSources.selectedValue, line: 4 }).then(onBreakpointAdd);
    40   }
    42   let onBpDebuggerAdd = false;
    43   let onBpEditorAdd = false;
    45   function onBreakpointAdd(aBreakpointClient) {
    46     ok(aBreakpointClient,
    47       "Breakpoint added, client received.");
    48     is(aBreakpointClient.location.url, gSources.selectedValue,
    49       "Breakpoint client url is the same.");
    50     is(aBreakpointClient.location.line, 6,
    51       "Breakpoint client line is new.");
    53     is(aBreakpointClient.requestedLocation.url, gSources.selectedValue,
    54       "Requested location url is correct");
    55     is(aBreakpointClient.requestedLocation.line, 4,
    56       "Requested location line is correct");
    58     onBpDebuggerAdd = true;
    59     maybeFinish();
    60   }
    62   function onEditorBreakpointAdd() {
    63     gEditor.off("breakpointAdded", onEditorBreakpointAdd);
    65     is(gEditor.getBreakpoints().length, 1,
    66       "There is only one breakpoint in the editor");
    68     ok(!gBreakpoints._getAdded({ url: gSources.selectedValue, line: 4 }),
    69       "There isn't any breakpoint added on an invalid line.");
    70     ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 4 }),
    71       "There isn't any breakpoint removed from an invalid line.");
    73     ok(gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }),
    74       "There is a breakpoint added on the actual line.");
    75     ok(!gBreakpoints._getRemoving({ url: gSources.selectedValue, line: 6 }),
    76       "There isn't any breakpoint removed from the actual line.");
    78     gBreakpoints._getAdded({ url: gSources.selectedValue, line: 6 }).then(aBreakpointClient => {
    79       is(aBreakpointClient.location.url, gSources.selectedValue,
    80         "Breakpoint client location url is correct.");
    81       is(aBreakpointClient.location.line, 6,
    82         "Breakpoint client location line is correct.");
    84       onBpEditorAdd = true;
    85       maybeFinish();
    86     });
    87   }
    89   function maybeFinish() {
    90     info("onBpDebuggerAdd: " + onBpDebuggerAdd);
    91     info("onBpEditorAdd: " + onBpEditorAdd);
    93     if (onBpDebuggerAdd && onBpEditorAdd) {
    94       resumeDebuggerThenCloseAndFinish(gPanel);
    95     }
    96   }
    97 }

mercurial