summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/Proxy/ownkeys-allowed-types.js
blob: 028ab851285d01aef763f7b9fb4c4ab9fbc9902e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function makeProxy(type) {
    return new Proxy({}, { ownKeys() { return [type]; } });
}

for (var type of [123, 12.5, true, false, undefined, null, {}, []]) {
    var proxy = makeProxy(type);
    assertThrowsInstanceOf(() => Object.ownKeys(proxy), TypeError);
    assertThrowsInstanceOf(() => Object.getOwnPropertyNames(proxy), TypeError);
}

type = Symbol();
proxy = makeProxy(type);
assertEq(Object.getOwnPropertySymbols(proxy)[0], type);

type = "abc";
proxy = makeProxy(type);
assertEq(Object.getOwnPropertyNames(proxy)[0], type);

if (typeof reportCompare === "function")
    reportCompare(true, true);