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

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

Issue 1668853002: [proxies] allow duplicate keys for [[OwnPropertyKeys]] trap. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addressing nits Created 4 years, 10 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 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
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-proxies --harmony-reflect 5 // Flags: --harmony-proxies --harmony-reflect
6 6
7 var target = { 7 var target = {
8 "target_one": 1 8 "target_one": 1
9 }; 9 };
10 target.__proto__ = { 10 target.__proto__ = {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 assertEquals([], Reflect.ownKeys(proxy)); 49 assertEquals([], Reflect.ownKeys(proxy));
50 keys.length = 1; 50 keys.length = 1;
51 assertEquals(["a"], Reflect.ownKeys(proxy)); 51 assertEquals(["a"], Reflect.ownKeys(proxy));
52 keys.length = 3; 52 keys.length = 3;
53 assertEquals(["a", "b", "c"], Reflect.ownKeys(proxy)); 53 assertEquals(["a", "b", "c"], Reflect.ownKeys(proxy));
54 // The spec wants to allow lengths up to 2^53, but we can't allocate arrays 54 // The spec wants to allow lengths up to 2^53, but we can't allocate arrays
55 // of that size, so we throw even for smaller values. 55 // of that size, so we throw even for smaller values.
56 keys.length = Math.pow(2, 33); 56 keys.length = Math.pow(2, 33);
57 assertThrows("Reflect.ownKeys(proxy)", RangeError); 57 assertThrows("Reflect.ownKeys(proxy)", RangeError);
58 58
59 // Check that we allow duplicated keys.
60 keys = ['a', 'a', 'a']
61 assertEquals(keys, Reflect.ownKeys(proxy));
62
59 // Non-Name results throw. 63 // Non-Name results throw.
60 keys = [1]; 64 keys = [1];
61 assertThrows("Reflect.ownKeys(proxy)", TypeError); 65 assertThrows("Reflect.ownKeys(proxy)", TypeError);
62 keys = [{}]; 66 keys = [{}];
63 assertThrows("Reflect.ownKeys(proxy)", TypeError); 67 assertThrows("Reflect.ownKeys(proxy)", TypeError);
64 keys = [{toString: function() { return "foo"; }}]; 68 keys = [{toString: function() { return "foo"; }}];
65 assertThrows("Reflect.ownKeys(proxy)", TypeError); 69 assertThrows("Reflect.ownKeys(proxy)", TypeError);
66 keys = [null]; 70 keys = [null];
67 assertThrows("Reflect.ownKeys(proxy)", TypeError); 71 assertThrows("Reflect.ownKeys(proxy)", TypeError);
68 72
69 // Step 17a: The trap result must include all non-configurable keys. 73 // Step 17a: The trap result must include all non-configurable keys.
70 Object.defineProperty(target, "nonconf", {value: 1, configurable: false}); 74 Object.defineProperty(target, "nonconf", {value: 1, configurable: false});
71 keys = ["foo"]; 75 keys = ["foo"];
72 assertThrows("Reflect.ownKeys(proxy)", TypeError); 76 assertThrows("Reflect.ownKeys(proxy)", TypeError);
73 keys = ["nonconf"]; 77 keys = ["nonconf"];
74 assertEquals(keys, Reflect.ownKeys(proxy)); 78 assertEquals(keys, Reflect.ownKeys(proxy));
75 79
80 // Check that we allow duplicated keys.
81 keys = ['nonconf', 'nonconf', 'nonconf']
82 assertEquals(keys, Reflect.ownKeys(proxy));
83
76 // Step 19a: The trap result must all keys of a non-extensible target. 84 // Step 19a: The trap result must all keys of a non-extensible target.
77 Object.preventExtensions(target); 85 Object.preventExtensions(target);
78 assertThrows("Reflect.ownKeys(proxy)", TypeError); 86 assertThrows("Reflect.ownKeys(proxy)", TypeError);
79 keys = ["nonconf", "target_one"]; 87 keys = ["nonconf", "target_one"];
80 assertEquals(keys, Reflect.ownKeys(proxy)); 88 assertEquals(keys, Reflect.ownKeys(proxy));
81 89
82 // Step 20: The trap result must not add keys to a non-extensible target. 90 // Step 20: The trap result must not add keys to a non-extensible target.
83 keys = ["nonconf", "target_one", "fantasy"]; 91 keys = ["nonconf", "target_one", "fantasy"];
84 assertThrows("Reflect.ownKeys(proxy)", TypeError); 92 assertThrows("Reflect.ownKeys(proxy)", TypeError);
93
94 // Check that we allow duplicated keys.
95 keys = ['nonconf', 'target_one', 'nonconf', 'nonconf', 'target_one',]
96 assertEquals(keys, Reflect.ownKeys(proxy));
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