michael@0: // onPop surfaces. michael@0: load(libdir + "asserts.js"); michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger(g); michael@0: michael@0: // Assigning a bogus value to Debugger.Frame.prototype.onPop raises a TypeError. michael@0: function test(badValue) { michael@0: print("store " + uneval(badValue) + " in Debugger.Frame.prototype.onPop"); michael@0: michael@0: var log; michael@0: dbg.onDebuggerStatement = function handleDebugger(frame) { michael@0: log += "d"; michael@0: assertThrowsInstanceOf(function () { frame.onPop = badValue; }, TypeError); michael@0: }; michael@0: michael@0: log = ""; michael@0: g.eval("debugger"); michael@0: assertEq(log, "d"); michael@0: } michael@0: michael@0: test(null); michael@0: test(false); michael@0: test(1); michael@0: test("stringy"); michael@0: test({}); michael@0: test([]); michael@0: michael@0: // Getting and setting the prototype's onPop is an error. michael@0: assertThrowsInstanceOf(function () { Debugger.Frame.prototype.onPop; }, TypeError); michael@0: assertThrowsInstanceOf( michael@0: function () { Debugger.Frame.prototype.onPop = function () {}; }, michael@0: TypeError); michael@0: michael@0: // The getters and setters correctly check the type of their 'this' argument. michael@0: var descriptor = Object.getOwnPropertyDescriptor(Debugger.Frame.prototype, 'onPop'); michael@0: assertEq(descriptor.configurable, true); michael@0: assertEq(descriptor.enumerable, false); michael@0: assertThrowsInstanceOf(function () { descriptor.get.call({}); }, TypeError); michael@0: assertThrowsInstanceOf(function () { descriptor.set.call({}, function() {}); }, TypeError);