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

Side by Side Diff: test/mjsunit/harmony/proxies-keys.js

Issue 1488873003: [proxies] Implement Symbol/DONT_ENUM filtering for GetKeys() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: moved filtering into KeyAccumulator Created 5 years 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-proxies
6
7 var target = {
8 target: 1
9 };
10 target.__proto__ = {
11 target_proto: 2
12 };
13
14 var handler = {
15 ownKeys: function(target) {
16 return ["foo", "bar", Symbol("baz"), "non-enum", "not-found"];
17 },
18 getOwnPropertyDescriptor: function(target, name) {
19 if (name == "non-enum") return {configurable: true};
20 if (name == "not-found") return undefined;
21 return {enumerable: true, configurable: true};
22 }
23 }
24
25 var proxy = new Proxy(target, handler);
26
27 // Object.keys() ignores symbols and non-enumerable keys.
28 assertEquals(["foo", "bar"], Object.keys(proxy));
29
30 // Edge case: no properties left after filtering.
31 handler.getOwnPropertyDescriptor = undefined;
32 assertEquals([], Object.keys(proxy));
33
34 // Throwing shouldn't crash.
35 handler.getOwnPropertyDescriptor = function() { throw new Number(1); };
36 assertThrows("Object.keys(proxy)", Number);
37
38 // Fall through to target if there is no trap.
39 handler.ownKeys = undefined;
40 assertEquals(["target"], Object.keys(proxy));
41 assertEquals(["target"], Object.keys(target));
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698