browser/devtools/debugger/test/browser_dbg_breakpoints-button-01.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 if the breakpoints toggle button works as advertised.
     6  */
     8 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html";
    10 function test() {
    11   let gTab, gDebuggee, gPanel, gDebugger;
    12   let gSources, gBreakpoints;
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    19     gSources = gDebugger.DebuggerView.Sources;
    20     gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    22     waitForSourceShown(gPanel, "-01.js")
    23       .then(addBreakpoints)
    24       .then(testDisableBreakpoints)
    25       .then(testEnableBreakpoints)
    26       .then(() => ensureThreadClientState(gPanel, "resumed"))
    27       .then(() => closeDebuggerAndFinish(gPanel))
    28       .then(null, aError => {
    29         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    30       });
    31   });
    33   function addBreakpoints() {
    34     return promise.resolve(null)
    35       .then(() => gPanel.addBreakpoint({ url: gSources.values[0], line: 5 }))
    36       .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 6 }))
    37       .then(() => gPanel.addBreakpoint({ url: gSources.values[1], line: 7 }))
    38       .then(() => ensureThreadClientState(gPanel, "resumed"));
    39   }
    41   function testDisableBreakpoints() {
    42     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED, 3);
    43     gSources.toggleBreakpoints();
    44     return finished.then(() => checkBreakpointsDisabled(true));
    45   }
    47   function testEnableBreakpoints() {
    48     let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED, 3);
    49     gSources.toggleBreakpoints();
    50     return finished.then(() => checkBreakpointsDisabled(false));
    51   }
    53   function checkBreakpointsDisabled(aState, aTotal = 3) {
    54     let breakpoints = gSources.getAllBreakpoints();
    56     is(breakpoints.length, aTotal,
    57       "Breakpoints should still be set.");
    58     is(breakpoints.filter(e => e.attachment.disabled == aState).length, aTotal,
    59       "Breakpoints should be " + (aState ? "disabled" : "enabled") + ".");
    60   }
    61 }

mercurial