browser/devtools/debugger/test/browser_dbg_breakpoints-new-script.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 771452: Make sure that setting a breakpoint in an inline source doesn't
     6  * add it twice.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    20     addBreakpoint();
    21   });
    22 }
    24 function addBreakpoint() {
    25   waitForSourceAndCaretAndScopes(gPanel, ".html", 16).then(() => {
    26     is(gDebugger.gThreadClient.state, "paused",
    27       "The debugger statement was reached.");
    28     ok(isCaretPos(gPanel, 16),
    29       "The source editor caret position is incorrect (1).");
    31     gPanel.addBreakpoint({ url: TAB_URL, line: 20 }).then(() => {
    32       testResume();
    33     });
    34   });
    36   gDebuggee.runDebuggerStatement();
    37 }
    39 function testResume() {
    40   is(gDebugger.gThreadClient.state, "paused",
    41     "The breakpoint wasn't hit yet.");
    43   gDebugger.gThreadClient.resume(() => {
    44     gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => {
    45       waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
    46         is(aPacket.why.type, "breakpoint",
    47           "Execution has advanced to the next breakpoint.");
    48         isnot(aPacket.why.type, "debuggerStatement",
    49           "The breakpoint was hit before the debugger statement.");
    50         ok(isCaretPos(gPanel, 20),
    51           "The source editor caret position is incorrect (2).");
    53         testBreakpointHit();
    54       });
    55     });
    57     EventUtils.sendMouseEvent({ type: "click" },
    58       gDebuggee.document.querySelector("button"),
    59       gDebuggee);
    60   });
    61 }
    63 function testBreakpointHit() {
    64   is(gDebugger.gThreadClient.state, "paused",
    65     "The breakpoint was hit.");
    67   gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => {
    68     waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
    69       is(aPacket.why.type, "debuggerStatement",
    70         "Execution has advanced to the next line.");
    71       isnot(aPacket.why.type, "breakpoint",
    72         "No ghost breakpoint was hit.");
    73       ok(isCaretPos(gPanel, 20),
    74         "The source editor caret position is incorrect (3).");
    76       resumeDebuggerThenCloseAndFinish(gPanel);
    77     });
    78   });
    80   EventUtils.sendMouseEvent({ type: "mousedown" },
    81     gDebugger.document.getElementById("resume"),
    82     gDebugger);
    83 }
    85 registerCleanupFunction(function() {
    86   gTab = null;
    87   gDebuggee = null;
    88   gPanel = null;
    89   gDebugger = null;
    90 });

mercurial