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

Unified Diff: test/mjsunit/harmony/proxy/proxy-getPrototypeOf.js

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: removing unreachable code Created 5 years, 1 month 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 | « test/mjsunit/harmony/proxies-with-unscopables.js ('k') | test/mjsunit/harmony/reflect-enumerate-opt.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/proxy/proxy-getPrototypeOf.js
diff --git a/test/mjsunit/harmony/proxy/proxy-getPrototypeOf.js b/test/mjsunit/harmony/proxy/proxy-getPrototypeOf.js
new file mode 100644
index 0000000000000000000000000000000000000000..df7525574e50cfeaa17d985fc87dcb78924d02d1
--- /dev/null
+++ b/test/mjsunit/harmony/proxy/proxy-getPrototypeOf.js
@@ -0,0 +1,39 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --harmony-proxies
+
+var target = { target: 1 };
+target.__proto__ = {};
+var handler = { handler: 1 };
+var proxy = new Proxy(target, handler);
+
+assertSame(Object.getPrototypeOf(proxy), target.__proto__ );
+
+target.__proto__ = [];
+assertSame(Object.getPrototypeOf(proxy), target.__proto__);
+
+handler.getPrototypeOf = function() {
+ return 1;
+}
+assertThrows(function() { Object.getPrototypeOf(proxy) }, TypeError);
+
+var target_prototype = {a:1, b:2};
+handler.getPrototypeOf = function() {
+ return target_prototype ;
+}
+assertSame(Object.getPrototypeOf(proxy), target_prototype);
+
+// Test with proxy target:
+var proxy2 = new Proxy(proxy, {});
+assertSame(Object.getPrototypeOf(proxy2), target_prototype);
+
+// Test with Proxy handler:
+// TODO(neis,cbruni): Uncomment once the get trap works again.
+// var proxy3_prototype = {};
+// var handler_proxy = new Proxy({
+// getPrototypeOf: function() { return proxy3_prototype }
+// }, {});
+// var proxy3 = new Proxy(target, handler_proxy);
+// assertSame(Object.getPrototypeOf(proxy3), target_prototype);
« no previous file with comments | « test/mjsunit/harmony/proxies-with-unscopables.js ('k') | test/mjsunit/harmony/reflect-enumerate-opt.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698