blob: a8f2279c4e8a36eb1a548d038375f604b472c148 (
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
|
function testNonEnumerableVisited() {
// Non-enumerable properties must still be included in the duplicate-property
// checking.
var proto1 = Object.create(null);
Object.defineProperty(proto1, "x", {enumerable: true, value: 1});
var proto2 = Object.create(proto1);
Object.defineProperty(proto2, "x", {enumerable: false, value: 1});
for (var p in proto2) {
throw "Shouldn't enumerate any properties";
}
var o = Object.create(proto2);
for (var p in o) {
throw "Shouldn't enumerate any properties";
}
}
testNonEnumerableVisited();
function testEnumerableOnProto() {
var iter = o => {
var props = [];
for (var p in o) { props.push(p); }
return props;
};
// Test dense elements on the proto chain are included.
var props = iter(Object.create({0: 1}));
assertEq(JSON.stringify(props), '["0"]');
// Test typed array elements on the proto chain are included.
props = iter(Object.create(new Int32Array(2)));
assertEq(JSON.stringify(props), '["0","1"]');
// Test sparse elements on the proto chain are included.
props = iter(Object.create({1234567: 1}));
assertEq(JSON.stringify(props), '["1234567"]');
}
testEnumerableOnProto();
|