1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Frame-onPop-17.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +// onPop surfaces. 1.5 +load(libdir + "asserts.js"); 1.6 + 1.7 +var g = newGlobal(); 1.8 +var dbg = new Debugger(g); 1.9 + 1.10 +// Assigning a bogus value to Debugger.Frame.prototype.onPop raises a TypeError. 1.11 +function test(badValue) { 1.12 + print("store " + uneval(badValue) + " in Debugger.Frame.prototype.onPop"); 1.13 + 1.14 + var log; 1.15 + dbg.onDebuggerStatement = function handleDebugger(frame) { 1.16 + log += "d"; 1.17 + assertThrowsInstanceOf(function () { frame.onPop = badValue; }, TypeError); 1.18 + }; 1.19 + 1.20 + log = ""; 1.21 + g.eval("debugger"); 1.22 + assertEq(log, "d"); 1.23 +} 1.24 + 1.25 +test(null); 1.26 +test(false); 1.27 +test(1); 1.28 +test("stringy"); 1.29 +test({}); 1.30 +test([]); 1.31 + 1.32 +// Getting and setting the prototype's onPop is an error. 1.33 +assertThrowsInstanceOf(function () { Debugger.Frame.prototype.onPop; }, TypeError); 1.34 +assertThrowsInstanceOf( 1.35 + function () { Debugger.Frame.prototype.onPop = function () {}; }, 1.36 + TypeError); 1.37 + 1.38 +// The getters and setters correctly check the type of their 'this' argument. 1.39 +var descriptor = Object.getOwnPropertyDescriptor(Debugger.Frame.prototype, 'onPop'); 1.40 +assertEq(descriptor.configurable, true); 1.41 +assertEq(descriptor.enumerable, false); 1.42 +assertThrowsInstanceOf(function () { descriptor.get.call({}); }, TypeError); 1.43 +assertThrowsInstanceOf(function () { descriptor.set.call({}, function() {}); }, TypeError);