browser/devtools/debugger/test/browser_dbg_breakpoints-disabled-reload.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  * Test that disabled breakpoints survive target navigation.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    10 function test() {
    11   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    12     let gDebugger = aPanel.panelWin;
    13     let gEvents = gDebugger.EVENTS;
    14     let gEditor = gDebugger.DebuggerView.editor;
    15     let gSources = gDebugger.DebuggerView.Sources;
    16     let gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    17     let gBreakpointLocation = { url: EXAMPLE_URL + "code_script-switching-01.js", line: 5 };
    19     Task.spawn(function() {
    20       yield waitForSourceShown(aPanel, "-01.js");
    21       yield aPanel.addBreakpoint(gBreakpointLocation);
    23       yield ensureThreadClientState(aPanel, "resumed");
    24       yield testWhenBreakpointEnabledAndFirstSourceShown();
    26       yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN);
    27       yield testWhenBreakpointEnabledAndSecondSourceShown();
    29       yield gSources.disableBreakpoint(gBreakpointLocation);
    30       yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN);
    31       yield testWhenBreakpointDisabledAndSecondSourceShown();
    33       yield gSources.enableBreakpoint(gBreakpointLocation);
    34       yield reloadActiveTab(aPanel, gEvents.SOURCE_SHOWN);
    35       yield testWhenBreakpointEnabledAndSecondSourceShown();
    37       yield resumeDebuggerThenCloseAndFinish(aPanel);
    38     });
    40     function verifyView({ disabled, visible }) {
    41       return Task.spawn(function() {
    42         // It takes a tick for the checkbox in the SideMenuWidget and the
    43         // gutter in the editor to get updated.
    44         yield waitForTick();
    46         let breakpointItem = gSources.getBreakpoint(gBreakpointLocation);
    47         let visibleBreakpoints = gEditor.getBreakpoints();
    48         is(!!breakpointItem.attachment.disabled, disabled,
    49           "The selected brekapoint state was correct.");
    50         is(breakpointItem.attachment.view.checkbox.hasAttribute("checked"), !disabled,
    51           "The selected brekapoint's checkbox state was correct.");
    53         // Source editor starts counting line and column numbers from 0.
    54         let breakpointLine = breakpointItem.attachment.line - 1;
    55         let matchedBreakpoints = visibleBreakpoints.filter(e => e.line == breakpointLine);
    56         is(!!matchedBreakpoints.length, visible,
    57           "The selected breakpoint's visibility in the editor was correct.");
    58       });
    59     }
    61     // All the following executeSoon()'s are required to spin the event loop
    62     // before causing the debuggee to pause, to allow functions to yield first.
    64     function testWhenBreakpointEnabledAndFirstSourceShown() {
    65       return Task.spawn(function() {
    66         yield ensureSourceIs(aPanel, "-01.js");
    67         yield verifyView({ disabled: false, visible: true });
    69         executeSoon(() => aDebuggee.firstCall());
    70         yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES);
    71         yield ensureSourceIs(aPanel, "-01.js");
    72         yield ensureCaretAt(aPanel, 5);
    73         yield verifyView({ disabled: false, visible: true });
    75         executeSoon(() => gDebugger.gThreadClient.resume());
    76         yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 1);
    77         yield verifyView({ disabled: false, visible: false });
    78       });
    79     }
    81     function testWhenBreakpointEnabledAndSecondSourceShown() {
    82       return Task.spawn(function() {
    83         yield ensureSourceIs(aPanel, "-02.js", true);
    84         yield verifyView({ disabled: false, visible: false });
    86         executeSoon(() => aDebuggee.firstCall());
    87         yield waitForSourceAndCaretAndScopes(aPanel, "-01.js", 1);
    88         yield verifyView({ disabled: false, visible: true });
    90         executeSoon(() => gDebugger.gThreadClient.resume());
    91         yield waitForSourceAndCaretAndScopes(aPanel, "-02.js", 1);
    92         yield verifyView({ disabled: false, visible: false });
    93       });
    94     }
    96     function testWhenBreakpointDisabledAndSecondSourceShown() {
    97       return Task.spawn(function() {
    98         yield ensureSourceIs(aPanel, "-02.js", true);
    99         yield verifyView({ disabled: true, visible: false });
   101         executeSoon(() => aDebuggee.firstCall());
   102         yield waitForDebuggerEvents(aPanel, gEvents.FETCHED_SCOPES);
   103         yield ensureSourceIs(aPanel, "-02.js");
   104         yield ensureCaretAt(aPanel, 1);
   105         yield verifyView({ disabled: true, visible: false });
   107         executeSoon(() => gDebugger.gThreadClient.resume());
   108         yield waitForDebuggerEvents(aPanel, gEvents.AFTER_FRAMES_CLEARED);
   109         yield ensureSourceIs(aPanel, "-02.js");
   110         yield ensureCaretAt(aPanel, 1);
   111         yield verifyView({ disabled: true, visible: false });
   112       });
   113     }
   114   });
   115 }

mercurial