browser/devtools/debugger/test/browser_dbg_conditional-breakpoints-04.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  * Make sure that conditional breakpoints with undefined expressions
     6  * are stored as plain breakpoints when re-enabling them.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
    11 function test() {
    12   let gTab, gDebuggee, gPanel, gDebugger;
    13   let gSources, gBreakpoints, gLocation;
    15   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    16     gTab = aTab;
    17     gDebuggee = aDebuggee;
    18     gPanel = aPanel;
    19     gDebugger = gPanel.panelWin;
    20     gSources = gDebugger.DebuggerView.Sources;
    21     gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    23     // This test forces conditional breakpoints to be evaluated on the
    24     // client-side
    25     var client = gPanel.target.client;
    26     client.mainRoot.traits.conditionalBreakpoints = false;
    28     gLocation = { url: gSources.selectedValue, line: 18 };
    30     waitForSourceAndCaretAndScopes(gPanel, ".html", 17)
    31       .then(addBreakpoint)
    32       .then(setDummyConditional)
    33       .then(() => {
    34         let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
    35         toggleBreakpoint();
    36         return finished;
    37       })
    38       .then(() => {
    39         let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
    40         toggleBreakpoint();
    41         return finished;
    42       })
    43       .then(testConditionalExpressionOnClient)
    44       .then(() => {
    45         let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
    46         openConditionalPopup();
    47         finished.then(() => ok(false, "The popup shouldn't have opened."));
    48         return waitForTime(1000);
    49       })
    50       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    51       .then(null, aError => {
    52         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    53       });
    55     gDebuggee.ermahgerd();
    56   });
    58   function addBreakpoint() {
    59     return gPanel.addBreakpoint(gLocation);
    60   }
    62   function setDummyConditional(aClient) {
    63     // This happens when a conditional expression input popup is shown
    64     // but the user doesn't type anything into it.
    65     aClient.conditionalExpression = "";
    66   }
    68   function toggleBreakpoint() {
    69     EventUtils.sendMouseEvent({ type: "click" },
    70       gDebugger.document.querySelector(".dbg-breakpoint-checkbox"),
    71       gDebugger);
    72   }
    74   function openConditionalPopup() {
    75     EventUtils.sendMouseEvent({ type: "click" },
    76       gDebugger.document.querySelector(".dbg-breakpoint"),
    77       gDebugger);
    78   }
    80   function testConditionalExpressionOnClient() {
    81     return gBreakpoints._getAdded(gLocation).then(aClient => {
    82       if ("conditionalExpression" in aClient) {
    83         ok(false, "A conditional expression shouldn't have been set.");
    84       } else {
    85         ok(true, "The conditional expression wasn't set, as expected.");
    86       }
    87     });
    88   }
    89 }

mercurial