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.

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

mercurial