js/src/jit-test/tests/debug/Debugger-debuggees-23.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 // Adding a debuggee allowed with scripts on stack from stranger places.
     3 // Test CCW.
     4 (function testCCW() {
     5   var g = newGlobal();
     6   var dbg = new Debugger;
     7   g.dbg = dbg;
     8   g.GLOBAL = g;
    10   g.turnOnDebugger = function () {
    11     dbg.addDebuggee(g);
    12   };
    14   g.eval("" + function f(d) {
    15     turnOnDebugger();
    16     assertEq(dbg.hasDebuggee(GLOBAL), true);
    17   });
    19   g.eval("(" + function test() {
    20     f(false);
    21     f(false);
    22     f(true);
    23     f(true);
    24   } + ")();");
    25 })();
    27 // Test getter.
    28 (function testGetter() {
    29   var g = newGlobal();
    30   g.dbg = new Debugger;
    31   g.GLOBAL = g;
    33   g.eval("" + function f(obj) {
    34     obj.foo;
    35     assertEq(dbg.hasDebuggee(GLOBAL), true);
    36   });
    38   g.eval("(" + function test() {
    39     f({ get foo() { dbg.addDebuggee(GLOBAL); } });
    40   } + ")();");
    41 })();
    43 // Test setter.
    44 (function testSetter() {
    45   var g = newGlobal();
    46   g.dbg = new Debugger;
    47   g.GLOBAL = g;
    49   g.eval("" + function f(obj) {
    50     obj.foo = 42;
    51     assertEq(dbg.hasDebuggee(GLOBAL), true);
    52   });
    54   g.eval("(" + function test() {
    55     f({ set foo(v) { dbg.addDebuggee(GLOBAL); } });
    56   } + ")();");
    57 })();
    59 // Test toString.
    60 (function testToString() {
    61   var g = newGlobal();
    62   g.dbg = new Debugger;
    63   g.GLOBAL = g;
    65   g.eval("" + function f(obj) {
    66     obj + "";
    67     assertEq(dbg.hasDebuggee(GLOBAL), true);
    68   });
    70   g.eval("(" + function test() {
    71     f({ toString: function () { dbg.addDebuggee(GLOBAL); }});
    72   } + ")();");
    73 })();
    75 // Test valueOf.
    76 (function testValueOf() {
    77   var g = newGlobal();
    78   g.dbg = new Debugger;
    79   g.GLOBAL = g;
    81   g.eval("" + function f(obj) {
    82     obj + "";
    83     assertEq(dbg.hasDebuggee(GLOBAL), true);
    84   });
    86   g.eval("(" + function test() {
    87     f({ valueOf: function () { dbg.addDebuggee(GLOBAL); }});
    88   } + ")();");
    89 })();
    91 // Test proxy trap.
    92 (function testProxyTrap() {
    93   var g = newGlobal();
    94   g.dbg = new Debugger;
    95   g.GLOBAL = g;
    97   g.eval("" + function f(proxy) {
    98     proxy["foo"];
    99     assertEq(dbg.hasDebuggee(GLOBAL), true);
   100   });
   102   g.eval("(" + function test() {
   103     var handler = { get: function () { dbg.addDebuggee(GLOBAL); } };
   104     var proxy = new Proxy({}, handler);
   105     f(proxy);
   106   } + ")();");
   107 })();

mercurial