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

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

Issue 1516843002: [proxy] fixing harmony/proxy.js tests and improving error messages + some drive-by fixes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: WIP fix protoype walks with access checks 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
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 5 // Flags: --harmony-proxies
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 assertThrows("for (var k in proxy) {}", TypeError); 65 assertThrows("for (var k in proxy) {}", TypeError);
66 } 66 }
67 67
68 TestNonStringKey(1); 68 TestNonStringKey(1);
69 TestNonStringKey(3.14); 69 TestNonStringKey(3.14);
70 TestNonStringKey(Symbol("foo")); 70 TestNonStringKey(Symbol("foo"));
71 TestNonStringKey({bad: "value"}); 71 TestNonStringKey({bad: "value"});
72 TestNonStringKey(null); 72 TestNonStringKey(null);
73 TestNonStringKey(undefined); 73 TestNonStringKey(undefined);
74 TestNonStringKey(true); 74 TestNonStringKey(true);
75
76 (function testProtoProxyEnumerate() {
77 var keys = ['a', 'b', 'c', 'd'];
78 var handler = {
79 enumerate() { return keys[Symbol.iterator]() },
80 has(target, key) { return false }
81 };
82 var proxy = new Proxy({}, handler);
83 var seen_keys = [];
84 for (var i in proxy) {
85 seen_keys.push(i);
86 }
87 assertEquals([], seen_keys);
88
89 handler.has = function(target, key) { return true };
90 for (var i in proxy) {
91 seen_keys.push(i);
92 }
93 assertEquals(keys, seen_keys);
94
95 o = {__proto__:proxy};
96 handler.has = function(target, key) { return false };
97 seen_keys = [];
98 for (var i in o) {
99 seen_keys.push(i);
100 }
101 assertEquals([], seen_keys);
102
103 handler.has = function(target, key) { return true };
104 seen_keys = [];
105 for (var i in o) {
106 seen_keys.push(i);
107 }
108 assertEquals(keys, seen_keys);
109 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698