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

Unified Diff: test/mjsunit/harmony/proxies-get-prototype-of.js

Issue 1491743010: Reland of [proxies] Make Object.prototype.isPrototypeOf work with proxies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/proxies-get-prototype-of.js
diff --git a/test/mjsunit/harmony/proxies-get-prototype-of.js b/test/mjsunit/harmony/proxies-get-prototype-of.js
index 364f5328f4fc173a406a1b94e5bdd942dc288b62..36f67356d556d39c06253f9e68ce3ee9105ed6d9 100644
--- a/test/mjsunit/harmony/proxies-get-prototype-of.js
+++ b/test/mjsunit/harmony/proxies-get-prototype-of.js
@@ -36,3 +36,58 @@
}, {});
var proxy3 = new Proxy(target, handler_proxy);
assertSame(Object.getPrototypeOf(proxy3), proxy3_prototype);
+
+
+// Some tests with Object.prototype.isPrototypeOf
+
+(function () {
+ var object = {};
+ var handler = {};
+ var proto = new Proxy({}, handler);
+ object.__proto__ = proto;
+
+ assertTrue(proto.isPrototypeOf(object));
+ assertTrue(Object.prototype.isPrototypeOf.call(proto, object));
+
+ handler.getPrototypeOf = function () { return Object.prototype };
+ assertTrue(proto.isPrototypeOf(object));
+ assertTrue(Object.prototype.isPrototypeOf.call(proto, object));
+ assertTrue(Object.prototype.isPrototypeOf(object));
+ assertFalse(Object.prototype.isPrototypeOf.call(Array.prototype, object));
+ assertFalse(Array.prototype.isPrototypeOf(object));
+
+ handler.getPrototypeOf = function () { return object };
+ assertTrue(Object.prototype.isPrototypeOf.call(proto, object));
+ assertTrue(proto.isPrototypeOf(object));
+ assertTrue(Object.prototype.isPrototypeOf.call(object, object));
+ assertTrue(object.isPrototypeOf(object));
+
+ handler.getPrototypeOf = function () { throw "foo" };
+ assertTrue(proto.isPrototypeOf(object));
+ assertTrue(Object.prototype.isPrototypeOf.call(proto, object));
+ assertThrows(()=> Object.prototype.isPrototypeOf(object));
+ assertThrows(()=> Object.prototype.isPrototypeOf.call(Array.prototype, object));
+ assertThrows(()=> Array.prototype.isPrototypeOf(object));
+})();
+
+(function () {
+ var handler = {};
+ var object = new Proxy({}, handler);
+ var proto = {};
+
+ assertFalse(Object.prototype.isPrototypeOf.call(object, object));
+ assertFalse(Object.prototype.isPrototypeOf.call(proto, object));
+ assertTrue(Object.prototype.isPrototypeOf.call(Object.prototype, object));
+
+ handler.getPrototypeOf = function () { return proto };
+ assertTrue(Object.prototype.isPrototypeOf.call(proto, object));
+ assertFalse(Object.prototype.isPrototypeOf.call({}, object));
+ assertTrue(Object.prototype.isPrototypeOf.call(Object.prototype, object));
+
+ handler.getPrototypeOf = function () { return object };
+ assertTrue(Object.prototype.isPrototypeOf.call(object, object));
+
+ handler.getPrototypeOf = function () { throw "foo" };
+ assertThrows(()=> Object.prototype.isPrototypeOf.call(object, object));
+ assertThrows(()=> Object.prototype.isPrototypeOf(object));
+})();
« 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