| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-proxy-object-internal-methods-and-internal-slots |
| 5 |
description: > |
| 6 |
Enumerate trap was removed and it should not be triggered anymore. |
| 7 |
includes: [compareArray.js] |
| 8 |
features: [Symbol.iterator] |
| 9 |
---*/ |
| 10 |
|
| 11 |
var x; |
| 12 |
var target = [1, 2, 3]; |
| 13 |
var p = new Proxy(target, { |
| 14 |
enumerate: function() { |
| 15 |
throw new Test262Error( |
| 16 |
"An enumerate property on handler object shouldn't trigger a Proxy trap" |
| 17 |
); |
| 18 |
} |
| 19 |
}); |
| 20 |
|
| 21 |
var forInResults = []; |
| 22 |
for (x in p) { |
| 23 |
forInResults.push(x); |
| 24 |
} |
| 25 |
|
| 26 |
assert(compareArray(forInResults, ["0", "1", "2"])); |
| 27 |
|
| 28 |
var forOfResults = []; |
| 29 |
for (x of p) { |
| 30 |
forOfResults.push(x); |
| 31 |
} |
| 32 |
|
| 33 |
assert(compareArray(forOfResults, [1, 2, 3])); |
| 34 |
|
| 35 |
var itor = p[Symbol.iterator](); |
| 36 |
var next = itor.next(); |
| 37 |
assert.sameValue(next.value, 1); |
| 38 |
assert.sameValue(next.done, false); |
| 39 |
next = itor.next(); |
| 40 |
assert.sameValue(next.value, 2); |
| 41 |
assert.sameValue(next.done, false); |
| 42 |
next = itor.next(); |
| 43 |
assert.sameValue(next.value, 3); |
| 44 |
assert.sameValue(next.done, false); |
| 45 |
next = itor.next(); |
| 46 |
assert.sameValue(next.value, undefined); |
| 47 |
assert.sameValue(next.done, true); |