summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/proxy/testDirectProxyGetOwnPropertyNames8.js
blob: bd4631ff844177b75cf7c525e5fdde86bf30c14f (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
42
// Return the names returned by the trap
var target = {};
Object.defineProperty(target, 'foo', {
    configurable: true
});

var handler = { ownKeys: () => [ 'bar' ] };

for (let p of [new Proxy(target, handler), Proxy.revocable(target, handler).proxy]) {
    var names = Object.getOwnPropertyNames(p);
    assertEq(names.length, 1);
    assertEq(names[0], 'bar');
}

var protoWithAB = Object.create(null, {
    a: {
        enumerable: true,
        configurable: true
    },
    b: {
        enumerable: false,
        configurable: true
    }
});
var objWithCD = Object.create(protoWithAB, {
    c: {
        enumerable: true,
        configurable: true
    },
    d: {
        enumerable: true,
        configurable: true
    }
});

handler = { ownKeys: () => [ 'c', 'e' ] };
for (let p of [new Proxy(objWithCD, handler), Proxy.revocable(objWithCD, handler).proxy]) {
    var names = Object.getOwnPropertyNames(p);
    assertEq(names.length, 2);
    assertEq(names[0], 'c');
    assertEq(names[1], 'e');
}