michael@0: // Test extracting frame.arguments element getters and calling them in michael@0: // various awkward ways. michael@0: michael@0: load(libdir + "asserts.js"); michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = Debugger(g); michael@0: var hits = 0; michael@0: var fframe, farguments, fgetter; michael@0: dbg.onDebuggerStatement = function (frame) { michael@0: if (hits === 0) { michael@0: fframe = frame; michael@0: farguments = frame.arguments; michael@0: fgetter = Object.getOwnPropertyDescriptor(farguments, "0").get; michael@0: assertEq(fgetter instanceof Function, true); michael@0: michael@0: // Calling the getter without an appropriate this-object michael@0: // fails, but shouldn't assert or crash. michael@0: assertThrowsInstanceOf(function () { fgetter.call(Math); }, TypeError); michael@0: } else { michael@0: // Since fframe is still on the stack, fgetter can be applied to it. michael@0: assertEq(fframe.live, true); michael@0: assertEq(fgetter.call(farguments), 100); michael@0: michael@0: // Since h was called without arguments, there is no argument 0. michael@0: assertEq(fgetter.call(frame.arguments), undefined); michael@0: } michael@0: hits++; michael@0: }; michael@0: michael@0: g.eval("function h() { debugger; }"); michael@0: g.eval("function f(x) { debugger; h(); }"); michael@0: g.f(100); michael@0: assertEq(hits, 2); michael@0: michael@0: // Now that fframe is no longer live, trying to get its arguments should throw. michael@0: assertEq(fframe.live, false); michael@0: assertThrowsInstanceOf(function () { fgetter.call(farguments); }, Error);