js/src/jit-test/tests/debug/Debugger-debuggees-23.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/Debugger-debuggees-23.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,107 @@
     1.4 +// Adding a debuggee allowed with scripts on stack from stranger places.
     1.5 +
     1.6 +// Test CCW.
     1.7 +(function testCCW() {
     1.8 +  var g = newGlobal();
     1.9 +  var dbg = new Debugger;
    1.10 +  g.dbg = dbg;
    1.11 +  g.GLOBAL = g;
    1.12 +
    1.13 +  g.turnOnDebugger = function () {
    1.14 +    dbg.addDebuggee(g);
    1.15 +  };
    1.16 +
    1.17 +  g.eval("" + function f(d) {
    1.18 +    turnOnDebugger();
    1.19 +    assertEq(dbg.hasDebuggee(GLOBAL), true);
    1.20 +  });
    1.21 +
    1.22 +  g.eval("(" + function test() {
    1.23 +    f(false);
    1.24 +    f(false);
    1.25 +    f(true);
    1.26 +    f(true);
    1.27 +  } + ")();");
    1.28 +})();
    1.29 +
    1.30 +// Test getter.
    1.31 +(function testGetter() {
    1.32 +  var g = newGlobal();
    1.33 +  g.dbg = new Debugger;
    1.34 +  g.GLOBAL = g;
    1.35 +
    1.36 +  g.eval("" + function f(obj) {
    1.37 +    obj.foo;
    1.38 +    assertEq(dbg.hasDebuggee(GLOBAL), true);
    1.39 +  });
    1.40 +
    1.41 +  g.eval("(" + function test() {
    1.42 +    f({ get foo() { dbg.addDebuggee(GLOBAL); } });
    1.43 +  } + ")();");
    1.44 +})();
    1.45 +
    1.46 +// Test setter.
    1.47 +(function testSetter() {
    1.48 +  var g = newGlobal();
    1.49 +  g.dbg = new Debugger;
    1.50 +  g.GLOBAL = g;
    1.51 +
    1.52 +  g.eval("" + function f(obj) {
    1.53 +    obj.foo = 42;
    1.54 +    assertEq(dbg.hasDebuggee(GLOBAL), true);
    1.55 +  });
    1.56 +
    1.57 +  g.eval("(" + function test() {
    1.58 +    f({ set foo(v) { dbg.addDebuggee(GLOBAL); } });
    1.59 +  } + ")();");
    1.60 +})();
    1.61 +
    1.62 +// Test toString.
    1.63 +(function testToString() {
    1.64 +  var g = newGlobal();
    1.65 +  g.dbg = new Debugger;
    1.66 +  g.GLOBAL = g;
    1.67 +
    1.68 +  g.eval("" + function f(obj) {
    1.69 +    obj + "";
    1.70 +    assertEq(dbg.hasDebuggee(GLOBAL), true);
    1.71 +  });
    1.72 +
    1.73 +  g.eval("(" + function test() {
    1.74 +    f({ toString: function () { dbg.addDebuggee(GLOBAL); }});
    1.75 +  } + ")();");
    1.76 +})();
    1.77 +
    1.78 +// Test valueOf.
    1.79 +(function testValueOf() {
    1.80 +  var g = newGlobal();
    1.81 +  g.dbg = new Debugger;
    1.82 +  g.GLOBAL = g;
    1.83 +
    1.84 +  g.eval("" + function f(obj) {
    1.85 +    obj + "";
    1.86 +    assertEq(dbg.hasDebuggee(GLOBAL), true);
    1.87 +  });
    1.88 +
    1.89 +  g.eval("(" + function test() {
    1.90 +    f({ valueOf: function () { dbg.addDebuggee(GLOBAL); }});
    1.91 +  } + ")();");
    1.92 +})();
    1.93 +
    1.94 +// Test proxy trap.
    1.95 +(function testProxyTrap() {
    1.96 +  var g = newGlobal();
    1.97 +  g.dbg = new Debugger;
    1.98 +  g.GLOBAL = g;
    1.99 +
   1.100 +  g.eval("" + function f(proxy) {
   1.101 +    proxy["foo"];
   1.102 +    assertEq(dbg.hasDebuggee(GLOBAL), true);
   1.103 +  });
   1.104 +
   1.105 +  g.eval("(" + function test() {
   1.106 +    var handler = { get: function () { dbg.addDebuggee(GLOBAL); } };
   1.107 +    var proxy = new Proxy({}, handler);
   1.108 +    f(proxy);
   1.109 +  } + ")();");
   1.110 +})();

mercurial