From 65241f1e932bd1746717efed23c139ad3cb0da06 Mon Sep 17 00:00:00 2001 From: Leonardo Balter Date: Sat, 6 Feb 2016 10:23:46 -0200 Subject: [PATCH] Add test to assert Proxy enumerate trap is not triggered anymore Ref #495 --- .../enumerate/removed-does-not-trigger.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/built-ins/Proxy/enumerate/removed-does-not-trigger.js diff --git a/test/built-ins/Proxy/enumerate/removed-does-not-trigger.js b/test/built-ins/Proxy/enumerate/removed-does-not-trigger.js new file mode 100644 index 0000000000..d4e32e402a --- /dev/null +++ b/test/built-ins/Proxy/enumerate/removed-does-not-trigger.js @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +id: sec-proxy-object-internal-methods-and-internal-slots +description: > + Enumerate trap was removed and it should not be triggered anymore. +includes: [compareArray.js] +features: [Symbol.iterator] +---*/ + +var x; +var target = [1, 2, 3]; +var p = new Proxy(target, { + enumerate: function() { + throw new Test262Error( + "An enumerate property on handler object shouldn't trigger a Proxy trap" + ); + } +}); + +var forInResults = []; +for (x in p) { + forInResults.push(x); +} + +assert(compareArray(forInResults, ["0", "1", "2"])); + +var forOfResults = []; +for (x of p) { + forOfResults.push(x); +} + +assert(compareArray(forOfResults, [1, 2, 3])); + +var itor = p[Symbol.iterator](); +var next = itor.next(); +assert.sameValue(next.value, 1); +assert.sameValue(next.done, false); +next = itor.next(); +assert.sameValue(next.value, 2); +assert.sameValue(next.done, false); +next = itor.next(); +assert.sameValue(next.value, 3); +assert.sameValue(next.done, false); +next = itor.next(); +assert.sameValue(next.value, undefined); +assert.sameValue(next.done, true);