browser/devtools/debugger/test/browser_dbg_server-conditional-bp-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 (with
     7  * server-side support)
     8  */
    10 const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
    12 function test() {
    13   let gTab, gDebuggee, gPanel, gDebugger;
    14   let gSources, gBreakpoints, gLocation;
    16   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    17     gTab = aTab;
    18     gDebuggee = aDebuggee;
    19     gPanel = aPanel;
    20     gDebugger = gPanel.panelWin;
    21     gSources = gDebugger.DebuggerView.Sources;
    22     gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    24     gLocation = { url: gSources.selectedValue, line: 18 };
    26     waitForSourceAndCaretAndScopes(gPanel, ".html", 17)
    27       .then(addBreakpoint)
    28       .then(setDummyConditional)
    29       .then(() => {
    30         let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
    31         toggleBreakpoint();
    32         return finished;
    33       })
    34       .then(() => {
    35         let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
    36         toggleBreakpoint();
    37         return finished;
    38       })
    39       .then(testConditionalExpressionOnClient)
    40       .then(() => {
    41         let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
    42         openConditionalPopup();
    43         finished.then(() => ok(false, "The popup shouldn't have opened."));
    44         return waitForTime(1000);
    45       })
    46       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    47       .then(null, aError => {
    48         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    49       });
    51     gDebuggee.ermahgerd();
    52   });
    54   function addBreakpoint() {
    55     return gPanel.addBreakpoint(gLocation);
    56   }
    58   function setDummyConditional(aClient) {
    59     // This happens when a conditional expression input popup is shown
    60     // but the user doesn't type anything into it.
    61     return gBreakpoints.updateCondition(aClient.location, '');
    62   }
    64   function toggleBreakpoint() {
    65     EventUtils.sendMouseEvent({ type: "click" },
    66       gDebugger.document.querySelector(".dbg-breakpoint-checkbox"),
    67       gDebugger);
    68   }
    70   function openConditionalPopup() {
    71     EventUtils.sendMouseEvent({ type: "click" },
    72       gDebugger.document.querySelector(".dbg-breakpoint"),
    73       gDebugger);
    74   }
    76   function testConditionalExpressionOnClient() {
    77     return gBreakpoints._getAdded(gLocation).then(aClient => {
    78       if ("condition" in aClient) {
    79         ok(false, "A conditional expression shouldn't have been set.");
    80       } else {
    81         ok(true, "The conditional expression wasn't set, as expected.");
    82       }
    83     });
    84   }
    85 }

mercurial