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
|
// Cull non-existent names returned by the trap.
var nullProtoAB = Object.create(null, {
a: {
enumerable: true,
configurable: true
},
b: {
enumerable: false,
configurable: true
}
});
var protoABWithCD = Object.create(nullProtoAB, {
c: {
enumerable: true,
configurable: true
},
d: {
enumerable: false,
configurable: true
}
});
var returnedNames;
var handler = { ownKeys: () => returnedNames };
for (let p of [new Proxy(protoABWithCD, handler), Proxy.revocable(protoABWithCD, handler).proxy]) {
returnedNames = [ 'e' ];
var names = Object.keys(p);
assertEq(names.length, 0);
returnedNames = [ 'c' ];
names = Object.keys(p);
assertEq(names.length, 1);
assertEq(names[0], 'c');
}
|