1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Frame-arguments-06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +// Test extracting frame.arguments element getters and calling them in 1.5 +// various awkward ways. 1.6 + 1.7 +load(libdir + "asserts.js"); 1.8 + 1.9 +var g = newGlobal(); 1.10 +var dbg = Debugger(g); 1.11 +var hits = 0; 1.12 +var fframe, farguments, fgetter; 1.13 +dbg.onDebuggerStatement = function (frame) { 1.14 + if (hits === 0) { 1.15 + fframe = frame; 1.16 + farguments = frame.arguments; 1.17 + fgetter = Object.getOwnPropertyDescriptor(farguments, "0").get; 1.18 + assertEq(fgetter instanceof Function, true); 1.19 + 1.20 + // Calling the getter without an appropriate this-object 1.21 + // fails, but shouldn't assert or crash. 1.22 + assertThrowsInstanceOf(function () { fgetter.call(Math); }, TypeError); 1.23 + } else { 1.24 + // Since fframe is still on the stack, fgetter can be applied to it. 1.25 + assertEq(fframe.live, true); 1.26 + assertEq(fgetter.call(farguments), 100); 1.27 + 1.28 + // Since h was called without arguments, there is no argument 0. 1.29 + assertEq(fgetter.call(frame.arguments), undefined); 1.30 + } 1.31 + hits++; 1.32 +}; 1.33 + 1.34 +g.eval("function h() { debugger; }"); 1.35 +g.eval("function f(x) { debugger; h(); }"); 1.36 +g.f(100); 1.37 +assertEq(hits, 2); 1.38 + 1.39 +// Now that fframe is no longer live, trying to get its arguments should throw. 1.40 +assertEq(fframe.live, false); 1.41 +assertThrowsInstanceOf(function () { fgetter.call(farguments); }, Error);