js/src/jit-test/tests/debug/Frame-arguments-06.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 // Test extracting frame.arguments element getters and calling them in
michael@0 2 // various awkward ways.
michael@0 3
michael@0 4 load(libdir + "asserts.js");
michael@0 5
michael@0 6 var g = newGlobal();
michael@0 7 var dbg = Debugger(g);
michael@0 8 var hits = 0;
michael@0 9 var fframe, farguments, fgetter;
michael@0 10 dbg.onDebuggerStatement = function (frame) {
michael@0 11 if (hits === 0) {
michael@0 12 fframe = frame;
michael@0 13 farguments = frame.arguments;
michael@0 14 fgetter = Object.getOwnPropertyDescriptor(farguments, "0").get;
michael@0 15 assertEq(fgetter instanceof Function, true);
michael@0 16
michael@0 17 // Calling the getter without an appropriate this-object
michael@0 18 // fails, but shouldn't assert or crash.
michael@0 19 assertThrowsInstanceOf(function () { fgetter.call(Math); }, TypeError);
michael@0 20 } else {
michael@0 21 // Since fframe is still on the stack, fgetter can be applied to it.
michael@0 22 assertEq(fframe.live, true);
michael@0 23 assertEq(fgetter.call(farguments), 100);
michael@0 24
michael@0 25 // Since h was called without arguments, there is no argument 0.
michael@0 26 assertEq(fgetter.call(frame.arguments), undefined);
michael@0 27 }
michael@0 28 hits++;
michael@0 29 };
michael@0 30
michael@0 31 g.eval("function h() { debugger; }");
michael@0 32 g.eval("function f(x) { debugger; h(); }");
michael@0 33 g.f(100);
michael@0 34 assertEq(hits, 2);
michael@0 35
michael@0 36 // Now that fframe is no longer live, trying to get its arguments should throw.
michael@0 37 assertEq(fframe.live, false);
michael@0 38 assertThrowsInstanceOf(function () { fgetter.call(farguments); }, Error);

mercurial