browser/devtools/debugger/test/browser_dbg_server-conditional-bp-03.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_server-conditional-bp-03.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +/**
     1.8 + * Test that conditional breakpoints survive disabled breakpoints
     1.9 + * (with server-side support)
    1.10 + */
    1.11 +
    1.12 +const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
    1.13 +
    1.14 +function test() {
    1.15 +  let gTab, gDebuggee, gPanel, gDebugger;
    1.16 +  let gSources, gBreakpoints, gLocation;
    1.17 +
    1.18 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.19 +    gTab = aTab;
    1.20 +    gDebuggee = aDebuggee;
    1.21 +    gPanel = aPanel;
    1.22 +    gDebugger = gPanel.panelWin;
    1.23 +    gSources = gDebugger.DebuggerView.Sources;
    1.24 +    gBreakpoints = gDebugger.DebuggerController.Breakpoints;
    1.25 +
    1.26 +    gLocation = { url: gSources.selectedValue, line: 18 };
    1.27 +
    1.28 +    waitForSourceAndCaretAndScopes(gPanel, ".html", 17)
    1.29 +      .then(addBreakpoint)
    1.30 +      .then(setConditional)
    1.31 +      .then(() => {
    1.32 +        let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_REMOVED);
    1.33 +        toggleBreakpoint();
    1.34 +        return finished;
    1.35 +      })
    1.36 +      .then(() => {
    1.37 +        let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_ADDED);
    1.38 +        toggleBreakpoint();
    1.39 +        return finished;
    1.40 +      })
    1.41 +      .then(testConditionalExpressionOnClient)
    1.42 +      .then(() => {
    1.43 +        let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
    1.44 +        openConditionalPopup();
    1.45 +        return finished;
    1.46 +      })
    1.47 +      .then(testConditionalExpressionInPopup)
    1.48 +      .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    1.49 +      .then(null, aError => {
    1.50 +        ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    1.51 +      });
    1.52 +
    1.53 +    gDebuggee.ermahgerd();
    1.54 +  });
    1.55 +
    1.56 +  function addBreakpoint() {
    1.57 +    return gPanel.addBreakpoint(gLocation);
    1.58 +  }
    1.59 +
    1.60 +  function setConditional(aClient) {
    1.61 +    return gBreakpoints.updateCondition(aClient.location, "hello");
    1.62 +  }
    1.63 +
    1.64 +  function toggleBreakpoint() {
    1.65 +    EventUtils.sendMouseEvent({ type: "click" },
    1.66 +      gDebugger.document.querySelector(".dbg-breakpoint-checkbox"),
    1.67 +      gDebugger);
    1.68 +  }
    1.69 +
    1.70 +  function openConditionalPopup() {
    1.71 +    EventUtils.sendMouseEvent({ type: "click" },
    1.72 +      gDebugger.document.querySelector(".dbg-breakpoint"),
    1.73 +      gDebugger);
    1.74 +  }
    1.75 +
    1.76 +  function testConditionalExpressionOnClient() {
    1.77 +    return gBreakpoints._getAdded(gLocation).then(aClient => {
    1.78 +      is(aClient.condition, "hello", "The expression is correct (1).");
    1.79 +    });
    1.80 +  }
    1.81 +
    1.82 +  function testConditionalExpressionInPopup() {
    1.83 +    let textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox");
    1.84 +    is(textbox.value, "hello", "The expression is correct (2).")
    1.85 +  }
    1.86 +}

mercurial