js/src/jit-test/tests/debug/resumption-08.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/resumption-08.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +// Check whether we respect resumption values when toggling debug mode on->off
     1.5 +// from various points with live scripts on the stack.
     1.6 +
     1.7 +var g = newGlobal();
     1.8 +var dbg = new Debugger;
     1.9 +
    1.10 +function reset() {
    1.11 +  dbg.onEnterFrame = undefined;
    1.12 +  dbg.onDebuggerStatement = undefined;
    1.13 +  dbg.addDebuggee(g);
    1.14 +  g.eval("(" + function test() {
    1.15 +    for (i = 0; i < 5; i++)
    1.16 +      f(42);
    1.17 +  } + ")();");
    1.18 +}
    1.19 +
    1.20 +g.eval("" + function f(d) {
    1.21 +  return g(d);
    1.22 +});
    1.23 +
    1.24 +g.eval("" + function g(d) {
    1.25 +  debugger;
    1.26 +  return d;
    1.27 +});
    1.28 +
    1.29 +function testResumptionValues(handlerSetter) {
    1.30 +  // Test normal return.
    1.31 +  reset();
    1.32 +  handlerSetter(undefined);
    1.33 +  assertEq(g.eval("(" + function test() { return f(42); } + ")();"), 42);
    1.34 +
    1.35 +  // Test forced return.
    1.36 +  reset();
    1.37 +  handlerSetter({ return: "not 42" });
    1.38 +  assertEq(g.eval("(" + function test() { return f(42); } + ")();"), "not 42");
    1.39 +
    1.40 +  // Test throw.
    1.41 +  reset();
    1.42 +  handlerSetter({ throw: "thrown 42" });
    1.43 +  try {
    1.44 +    g.eval("(" + function test() { return f(42); } + ")();");;
    1.45 +  } catch (e) {
    1.46 +    assertEq(e, "thrown 42");
    1.47 +  }
    1.48 +}
    1.49 +
    1.50 +// Turn off from within the prologue.
    1.51 +testResumptionValues(function (resumptionVal) {
    1.52 +  dbg.onEnterFrame = function (frame) {
    1.53 +    if (frame.older) {
    1.54 +      if (frame.older.older) {
    1.55 +        dbg.removeDebuggee(g);
    1.56 +        return resumptionVal;
    1.57 +      }
    1.58 +    }
    1.59 +  };
    1.60 +});
    1.61 +
    1.62 +// Turn off from within the epilogue.
    1.63 +testResumptionValues(function (resumptionVal) {
    1.64 +  dbg.onEnterFrame = function (frame) {
    1.65 +    if (frame.older) {
    1.66 +      if (frame.older.older) {
    1.67 +        frame.onPop = function () {
    1.68 +          dbg.removeDebuggee(g);
    1.69 +          return resumptionVal;
    1.70 +        };
    1.71 +      }
    1.72 +    }
    1.73 +  };
    1.74 +});
    1.75 +
    1.76 +// Turn off from within debugger statement handler.
    1.77 +testResumptionValues(function (resumptionVal) {
    1.78 +  dbg.onDebuggerStatement = function (frame) {
    1.79 +    dbg.removeDebuggee(g);
    1.80 +    return resumptionVal;
    1.81 +  };
    1.82 +});
    1.83 +
    1.84 +// Turn off from within debug trap handler.
    1.85 +testResumptionValues(function (resumptionVal) {
    1.86 +  dbg.onEnterFrame = function (frame) {
    1.87 +    if (frame.older) {
    1.88 +      if (frame.older.older) {
    1.89 +        frame.onStep = function () {
    1.90 +          dbg.removeDebuggee(g);
    1.91 +          return resumptionVal;
    1.92 +        }
    1.93 +      }
    1.94 +    }
    1.95 +  };
    1.96 +});

mercurial