summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onPop-17.js
blob: 5cb382403775665b0fc87b749510edd5b30e1865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// onPop surfaces.
load(libdir + "asserts.js");

var g = newGlobal();
var dbg = new Debugger(g);

// Assigning a bogus value to Debugger.Frame.prototype.onPop raises a TypeError.
function test(badValue) {
    print("store " + uneval(badValue) + " in Debugger.Frame.prototype.onPop");

    var log;
    dbg.onDebuggerStatement = function handleDebugger(frame) {
        log += "d";
        assertThrowsInstanceOf(function () { frame.onPop = badValue; }, TypeError);
    };

    log = "";
    g.eval("debugger");
    assertEq(log, "d");
}

test(null);
test(false);
test(1);
test("stringy");
test(Symbol("symbolic"));
test({});
test([]);

// Getting and setting the prototype's onPop is an error.
assertThrowsInstanceOf(function () { Debugger.Frame.prototype.onPop; }, TypeError);
assertThrowsInstanceOf(
    function () { Debugger.Frame.prototype.onPop = function () {}; },
    TypeError);

// The getters and setters correctly check the type of their 'this' argument.
var descriptor = Object.getOwnPropertyDescriptor(Debugger.Frame.prototype, 'onPop');
assertEq(descriptor.configurable, true);
assertEq(descriptor.enumerable, false);
assertThrowsInstanceOf(function () { descriptor.get.call({}); }, TypeError);
assertThrowsInstanceOf(function () { descriptor.set.call({}, function() {}); }, TypeError);