Debian Codegraph @

js/src/jit-test/tests/debug/Frame-arguments-01.js

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