browser/devtools/debugger/test/browser_dbg_step-out.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_step-out.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,85 @@
     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 + * Make sure that stepping out of a function displays the right return value.
     1.9 + */
    1.10 +
    1.11 +const TAB_URL = EXAMPLE_URL + "doc_step-out.html";
    1.12 +
    1.13 +let gTab, gDebuggee, gPanel, gDebugger;
    1.14 +let gVars;
    1.15 +
    1.16 +function test() {
    1.17 +  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    1.18 +    gTab = aTab;
    1.19 +    gDebuggee = aDebuggee;
    1.20 +    gPanel = aPanel;
    1.21 +    gDebugger = gPanel.panelWin;
    1.22 +    gVars = gDebugger.DebuggerView.Variables;
    1.23 +
    1.24 +    testNormalReturn();
    1.25 +  });
    1.26 +}
    1.27 +
    1.28 +function testNormalReturn() {
    1.29 +  waitForSourceAndCaretAndScopes(gPanel, ".html", 17).then(() => {
    1.30 +    waitForCaretAndScopes(gPanel, 19).then(() => {
    1.31 +      let innerScope = gVars.getScopeAtIndex(0);
    1.32 +      let returnVar = innerScope.get("<return>");
    1.33 +
    1.34 +      is(returnVar.name, "<return>",
    1.35 +        "Should have the right property name for the returned value.");
    1.36 +      is(returnVar.value, 10,
    1.37 +        "Should have the right property value for the returned value.");
    1.38 +
    1.39 +      resumeDebuggee().then(() => testReturnWithException());
    1.40 +    });
    1.41 +
    1.42 +    EventUtils.sendMouseEvent({ type: "mousedown" },
    1.43 +      gDebugger.document.getElementById("step-out"),
    1.44 +      gDebugger);
    1.45 +  });
    1.46 +
    1.47 +  EventUtils.sendMouseEvent({ type: "click" },
    1.48 +    gDebuggee.document.getElementById("return"),
    1.49 +    gDebuggee);
    1.50 +}
    1.51 +
    1.52 +function testReturnWithException() {
    1.53 +  waitForCaretAndScopes(gPanel, 24).then(() => {
    1.54 +    waitForCaretAndScopes(gPanel, 27).then(() => {
    1.55 +      let innerScope = gVars.getScopeAtIndex(0);
    1.56 +      let exceptionVar = innerScope.get("<exception>");
    1.57 +
    1.58 +      is(exceptionVar.name, "<exception>",
    1.59 +        "Should have the right property name for the returned value.");
    1.60 +      is(exceptionVar.value, "boom",
    1.61 +        "Should have the right property value for the returned value.");
    1.62 +
    1.63 +      resumeDebuggee().then(() => closeDebuggerAndFinish(gPanel));
    1.64 +    });
    1.65 +
    1.66 +    EventUtils.sendMouseEvent({ type: "mousedown" },
    1.67 +      gDebugger.document.getElementById("step-out"),
    1.68 +      gDebugger);
    1.69 +  });
    1.70 +
    1.71 +  EventUtils.sendMouseEvent({ type: "click" },
    1.72 +    gDebuggee.document.getElementById("throw"),
    1.73 +    gDebuggee);
    1.74 +}
    1.75 +
    1.76 +function resumeDebuggee() {
    1.77 +  let deferred = promise.defer();
    1.78 +  gDebugger.gThreadClient.resume(deferred.resolve);
    1.79 +  return deferred.promise;
    1.80 +}
    1.81 +
    1.82 +registerCleanupFunction(function() {
    1.83 +  gTab = null;
    1.84 +  gDebuggee = null;
    1.85 +  gPanel = null;
    1.86 +  gDebugger = null;
    1.87 +  gVars = null;
    1.88 +});

mercurial