summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/proxy/freeze-proxy.js
blob: ff82c50fd3008cee238cf0e811b381fcc08e174c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var called = [];
var proxy = new Proxy({a: 1, get b() {}}, {
    getOwnPropertyDescriptor(target, P) {
        called.push("getOwnPropertyDescriptor");
        return Object.getOwnPropertyDescriptor(target, P);
    },
    defineProperty(target, P, desc) {
        called.push("defineProperty");
        if (P == "a") {
            assertEq(Object.getOwnPropertyNames(desc).length, 2);
            assertEq(desc.configurable, false);
            assertEq(desc.writable, false);
        } else {
            assertEq(Object.getOwnPropertyNames(desc).length, 1);
            assertEq(desc.configurable, false);
        }
        return Object.defineProperty(target, P, desc);
    }
});

Object.freeze(proxy);
assertEq(called.toString(), "getOwnPropertyDescriptor,defineProperty,getOwnPropertyDescriptor,defineProperty");