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

Unified Diff: test/mjsunit/harmony/reflect-construct.js

Issue 1499923002: Reflect.construct / Proxies: Fall back to intrinsicDefaultProto for non-instance prototypes (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/objects.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/reflect-construct.js
diff --git a/test/mjsunit/harmony/reflect-construct.js b/test/mjsunit/harmony/reflect-construct.js
index 8e43b19a34269e3687ad9bc7f43cf1bb5239e535..14f04b1a3ed16dc8efb54c48059fc6cce8ace746 100644
--- a/test/mjsunit/harmony/reflect-construct.js
+++ b/test/mjsunit/harmony/reflect-construct.js
@@ -284,3 +284,94 @@
assertTrue(o.__proto__ === g.prototype);
assertTrue(o.__proto__ !== f.prototype);
})();
+
+(function () {
+ var realm1 = Realm.create();
+ var realm2 = Realm.create();
+
+ var well_known_intrinsic_constructors = [
+ "Array",
+ "ArrayBuffer",
+ "Boolean",
+ ["DataView", [new ArrayBuffer()]],
+ "Date",
+ // "Error",
+ // "EvalError",
+ "Float32Array",
+ "Float64Array",
+ "Function",
+ "((function*(){}).constructor)", // GeneratorFunction
+ "Int8Array",
+ "Int16Array",
+ "Int32Array",
+ "Map",
+ "Number",
+ "Object",
+ // "Promise",
+ // "RangeError",
+ // "ReferenceError",
+ "RegExp",
+ "Set",
+ "String",
+ // "SyntaxError",
+ // %TypedArray%?
+ // "TypeError",
+ "Uint8Array",
+ "Uint8ClampedArray",
+ "Uint16Array",
+ "Uint32Array",
+ // "URIError",
+ "WeakMap",
+ "WeakSet"
+ ];
+
+ function getname(v) {
+ return typeof v === "string" ? v : v[0];
+ }
+
+ function getargs(v) {
+ return typeof v === "string" ? [] : v[1];
+ }
+
+ function test_intrinsic_prototype(name) {
+ var own = Realm.eval(realm1, name);
+
+ // Ensure that constructor.prototype is non-writable, non-configurable.
+ var desc = Object.getOwnPropertyDescriptor(own, "prototype");
+ assertFalse(desc.configurable, name);
+ assertFalse(desc.writable, name);
+ }
+
+ for (var intrinsic of well_known_intrinsic_constructors) {
+ test_intrinsic_prototype(getname(intrinsic));
+ }
+
+ function function_with_non_instance_prototype(realm) {
+ var f = Realm.eval(realm, "(function(){})");
+ f.prototype = 1;
+ return f;
+ }
+
+ function test_intrinsic_default(realm, name, args, convert) {
+ var own = Realm.eval(realm1, name);
+ var other = Realm.eval(realm, name);
+ var o = Reflect.construct(
+ convert(own), args, function_with_non_instance_prototype(realm));
+
+ // Ensure the intrisicDefaultProto is fetched from the correct realm.
+ assertTrue(realm == realm1 || o.__proto__ !== own.prototype, [...arguments]);
+ assertTrue(o.__proto__ === other.prototype, [...arguments]);
+ }
+
+ function test_all(test, convert) {
+ for (var intrinsic of well_known_intrinsic_constructors) {
+ for (var realm of [realm1, realm2]) {
+ test(realm, getname(intrinsic), getargs(intrinsic), convert);
+ }
+ }
+ }
+
+ test_all(test_intrinsic_default, (v)=>v);
+ test_all(test_intrinsic_default,
+ (v)=>{ "use strict"; return class extends v {}});
+})();
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698