Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: test/mjsunit/es6/proxies-keys.js

Issue 2176113009: [keys] Trigger [[getOwnPropertyDescriptor]] trap for Object.keys (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: eval scoping is hard Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-forin.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/proxies-keys.js
diff --git a/test/mjsunit/es6/proxies-keys.js b/test/mjsunit/es6/proxies-keys.js
index 2635ac3407379948c9075a3fd3ffa00a66c7b659..4781ae37f407f6743f5182d274cc611c852a65d2 100644
--- a/test/mjsunit/es6/proxies-keys.js
+++ b/test/mjsunit/es6/proxies-keys.js
@@ -2,45 +2,50 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var target = {
- target: 1
-};
-target.__proto__ = {
- target_proto: 2
-};
+(function testObjectKeys() {
+ var target = {
+ target: 1
+ };
+ target.__proto__ = {
+ target_proto: 2
+ };
-var handler = {
- ownKeys: function(target) {
- return ["foo", "bar", Symbol("baz"), "non-enum", "not-found"];
- },
- getOwnPropertyDescriptor: function(target, name) {
- if (name == "non-enum") return {configurable: true};
- if (name == "not-found") return undefined;
- return {enumerable: true, configurable: true};
+ var handler = {
+ ownKeys: function(target) {
+ return ["foo", "bar", Symbol("baz"), "non-enum", "not-found"];
+ },
+ getOwnPropertyDescriptor: function(target, name) {
+ if (name == "non-enum") return {configurable: true};
+ if (name == "not-found") return undefined;
+ return {enumerable: true, configurable: true};
+ }
}
-}
-var proxy = new Proxy(target, handler);
+ var proxy = new Proxy(target, handler);
-// Object.keys() ignores symbols and non-enumerable keys.
-assertEquals(["foo", "bar"], Object.keys(proxy));
+ // Object.keys() ignores symbols and non-enumerable keys.
+ assertEquals(["foo", "bar"], Object.keys(proxy));
-// Edge case: no properties left after filtering.
-handler.getOwnPropertyDescriptor = undefined;
-assertEquals([], Object.keys(proxy));
+ // Edge case: no properties left after filtering.
+ handler.getOwnPropertyDescriptor = undefined;
+ assertEquals([], Object.keys(proxy));
-// Throwing shouldn't crash.
-handler.getOwnPropertyDescriptor = function() { throw new Number(1); };
-assertThrows("Object.keys(proxy)", Number);
+ // Throwing shouldn't crash.
+ handler.getOwnPropertyDescriptor = function() { throw new Number(1); };
+ assertThrows(() => Object.keys(proxy), Number);
-// Fall through to target if there is no trap.
-handler.ownKeys = undefined;
-assertEquals(["target"], Object.keys(proxy));
-assertEquals(["target"], Object.keys(target));
+ // Fall through to getOwnPropertyDescriptor if there is no trap.
+ handler.ownKeys = undefined;
+ assertThrows(() => Object.keys(proxy), Number);
-var proxy2 = new Proxy(proxy, {});
-assertEquals(["target"], Object.keys(proxy2));
+ // Fall through to target if there is no trap.
+ handler.getOwnPropertyDescriptor = undefined;
+ assertEquals(["target"], Object.keys(proxy));
+ assertEquals(["target"], Object.keys(target));
+ var proxy2 = new Proxy(proxy, {});
+ assertEquals(["target"], Object.keys(proxy2));
+})();
(function testForSymbols() {
var symbol = Symbol();
« no previous file with comments | « src/runtime/runtime-forin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698