|
1 // onPop surfaces. |
|
2 load(libdir + "asserts.js"); |
|
3 |
|
4 var g = newGlobal(); |
|
5 var dbg = new Debugger(g); |
|
6 |
|
7 // Assigning a bogus value to Debugger.Frame.prototype.onPop raises a TypeError. |
|
8 function test(badValue) { |
|
9 print("store " + uneval(badValue) + " in Debugger.Frame.prototype.onPop"); |
|
10 |
|
11 var log; |
|
12 dbg.onDebuggerStatement = function handleDebugger(frame) { |
|
13 log += "d"; |
|
14 assertThrowsInstanceOf(function () { frame.onPop = badValue; }, TypeError); |
|
15 }; |
|
16 |
|
17 log = ""; |
|
18 g.eval("debugger"); |
|
19 assertEq(log, "d"); |
|
20 } |
|
21 |
|
22 test(null); |
|
23 test(false); |
|
24 test(1); |
|
25 test("stringy"); |
|
26 test({}); |
|
27 test([]); |
|
28 |
|
29 // Getting and setting the prototype's onPop is an error. |
|
30 assertThrowsInstanceOf(function () { Debugger.Frame.prototype.onPop; }, TypeError); |
|
31 assertThrowsInstanceOf( |
|
32 function () { Debugger.Frame.prototype.onPop = function () {}; }, |
|
33 TypeError); |
|
34 |
|
35 // The getters and setters correctly check the type of their 'this' argument. |
|
36 var descriptor = Object.getOwnPropertyDescriptor(Debugger.Frame.prototype, 'onPop'); |
|
37 assertEq(descriptor.configurable, true); |
|
38 assertEq(descriptor.enumerable, false); |
|
39 assertThrowsInstanceOf(function () { descriptor.get.call({}); }, TypeError); |
|
40 assertThrowsInstanceOf(function () { descriptor.set.call({}, function() {}); }, TypeError); |