js/src/jit-test/tests/debug/Frame-arguments-01.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 // Frame.prototype.arguments with primitive values
michael@0 2
michael@0 3 var g = newGlobal();
michael@0 4 g.args = null;
michael@0 5 var dbg = new Debugger(g);
michael@0 6 var hits;
michael@0 7 var v;
michael@0 8 dbg.onDebuggerStatement = function (frame) {
michael@0 9 hits++;
michael@0 10 var args = frame.arguments;
michael@0 11 assertEq(args instanceof Array, true);
michael@0 12 assertEq(Array.isArray(args), false);
michael@0 13 assertEq(args, frame.arguments);
michael@0 14 assertEq(args.length, g.args.length);
michael@0 15 for (var i = 0; i < args.length; i++)
michael@0 16 assertEq(args[i], g.args[i]);
michael@0 17 };
michael@0 18
michael@0 19 // no formal parameters
michael@0 20 g.eval("function f() { debugger; }");
michael@0 21
michael@0 22 hits = 0;
michael@0 23 g.eval("args = []; f();");
michael@0 24 g.eval("this.f();");
michael@0 25 g.eval("args = ['hello', 3.14, true, false, null, undefined]; f.apply(undefined, args);");
michael@0 26 g.eval("f('hello', 3.14, true, false, null, undefined);");
michael@0 27 g.eval("args = [-0, NaN, -1/0]; this.f(-0, NaN, -1/0);");
michael@0 28 assertEq(hits, 5);
michael@0 29
michael@0 30 // with formal parameters
michael@0 31 g.eval("function f(a, b) { debugger; }");
michael@0 32
michael@0 33 hits = 0;
michael@0 34 g.eval("args = []; f();");
michael@0 35 g.eval("this.f();");
michael@0 36 g.eval("args = ['a', 'b']; f('a', 'b');");
michael@0 37 g.eval("this.f('a', 'b');");
michael@0 38 g.eval("f.bind(null, 'a')('b');");
michael@0 39 assertEq(hits, 5);

mercurial