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

Unified Diff: test/mjsunit/harmony/proxies-for.js

Issue 1748923003: [proxies] use [[GetPrototypeOf]] trap in for-in (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: test/mjsunit/harmony/proxies-for.js
diff --git a/test/mjsunit/harmony/proxies-for.js b/test/mjsunit/harmony/proxies-for.js
index e52ee4303102a70a5bd57de7011910f69aaef80c..a9ab8ad841bb5202dc46b391f3d1e9104a2cfbd3 100644
--- a/test/mjsunit/harmony/proxies-for.js
+++ b/test/mjsunit/harmony/proxies-for.js
@@ -125,16 +125,45 @@ TestForInThrow(new Proxy({}, {
}
}));
-(function() {
- var p = new Proxy({}, {ownKeys:function() { return ["0"]; }});
+
+function keys(object) {
+ var keys = [];
+ for (var k in object) {
+ keys.push(k);
+ }
+ return keys;
+}
+
+(function testKeysProxyOnProto() {
+ var p = new Proxy({}, {ownKeys() { return ["0"]; }});
var o = [0];
o.__proto__ = p;
- var keys = [];
- for (var k in o) { keys.push(k); };
- assertEquals(["0"], keys);
+ assertEquals(["0"], keys(o));
neis 2016/03/01 13:40:31 Also do this test when o is empty, for instance.
Camillo Bruni 2016/03/01 19:04:57 done.
})();
+(function testKeysProxyProto() {
+ var target = {t1:true, t2:true};
+ var handler = {}
+ var proxy = new Proxy(target, handler);
+
+ assertEquals(["t1", "t2"], keys(proxy));
+
+ target.__proto__ = {p1:true, p2:true};
+ assertEquals(["t1", "t2", "p1", "p2"], keys(proxy));
+
+ handler.getPrototypeOf = function(target) {
+ return {p3:true, p4:true};
+ };
+ assertEquals(["t1", "t2"], keys(proxy));
+ handler.has = function() { return true };
+ assertEquals(["t1", "t2", "p3", "p4"], keys(proxy));
+
+ handler.getPrototypeOf = function() { throw "error" };
+ assertThrowsEquals(()=>{ keys(proxy) }, "error");
+})();
+
+
(function () {
- var p = new Proxy({}, {ownKeys: function() { return ["1", Symbol(), "2"] }});
+ var p = new Proxy({}, {ownKeys() { return ["1", Symbol(), "2"] }});
assertEquals(["1","2"], Object.getOwnPropertyNames(p));
neis 2016/03/01 13:40:31 Also call getOwnPropertySymbols here.
Camillo Bruni 2016/03/01 19:04:57 done.
})();

Powered by Google App Engine
This is Rietveld 408576698