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

Unified Diff: test/mjsunit/es6/classes-subclass-builtins.js

Issue 1510753005: Fix Function subclassing. (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
« src/objects.cc ('K') | « src/transitions-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/classes-subclass-builtins.js
diff --git a/test/mjsunit/es6/classes-subclass-builtins.js b/test/mjsunit/es6/classes-subclass-builtins.js
index 5ecca0ed986f4824573a11f6044007ea4b1e5dc3..db0604249b8c0c69d3e00bd71c6665c08da28c93 100644
--- a/test/mjsunit/es6/classes-subclass-builtins.js
+++ b/test/mjsunit/es6/classes-subclass-builtins.js
@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Flags: --allow-natives-syntax --harmony-reflect --harmony-regexp-subclass
-// Flags: --expose-gc
+// Flags: --expose-gc --strong-mode
"use strict";
@@ -78,26 +78,52 @@ function checkPrototypeChain(object, constructors) {
constructor(...args) {
assertFalse(new.target === undefined);
super(...args);
+ // Strong functions are not extensible, so don't add fields.
+ if (args[args.length - 1].indexOf("use strong") >= 0) return;
this.a = 42;
this.d = 4.2;
this.o = {foo:153};
}
}
-
- var o = new A("this.foo = 113;");
- assertTrue(o instanceof Object);
- assertTrue(o instanceof Function);
- assertTrue(o instanceof A);
- assertEquals("function", typeof o);
- checkPrototypeChain(o, [A, Function, Object]);
- assertEquals(42, o.a);
- assertEquals(4.2, o.d);
- assertEquals(153, o.o.foo);
- var oo = new o();
+ var sloppy_func = new A("");
+ var strict_func = new A("'use strict';");
+ assertNull(sloppy_func.caller);
+ assertThrows("strict_f.caller");
+ assertNull(Object.getOwnPropertyDescriptor(sloppy_func, "caller").value);
+ assertEquals(undefined, Object.getOwnPropertyDescriptor(strict_func, "caller"));
+
+ var sloppy_func = new A("this.foo = 113;");
+ assertTrue(undefined !== sloppy_func.prototype);
+ sloppy_func.prototype.bar = 377;
+ assertTrue(sloppy_func instanceof Object);
+ assertTrue(sloppy_func instanceof Function);
+ assertTrue(sloppy_func instanceof A);
+ assertEquals("function", typeof sloppy_func);
+ checkPrototypeChain(sloppy_func, [A, Function, Object]);
+ assertEquals(42, sloppy_func.a);
+ assertEquals(4.2, sloppy_func.d);
+ assertEquals(153, sloppy_func.o.foo);
+ var oo = new sloppy_func();
assertEquals(113, oo.foo);
+ assertEquals(377, oo.bar);
- var o1 = new A("return 312;");
- assertTrue(%HaveSameMap(o, o1));
+ var sloppy_func1 = new A("return 312;");
+ assertTrue(%HaveSameMap(sloppy_func, sloppy_func1));
+
+
+ var strict_func = new A("'use strict'; this.foo = 113;");
+ assertFalse(%HaveSameMap(strict_func, sloppy_func));
+
+ var strict_func1 = new A("'use strict'; return 312;");
+ assertTrue(%HaveSameMap(strict_func, strict_func1));
+
+
+ var strong_func = new A("'use strong'; this.foo = 113");
+ assertFalse(%HaveSameMap(strong_func, sloppy_func));
+ assertFalse(%HaveSameMap(strong_func, strict_func));
+
+ var strong_func1 = new A("'use strong'; return 312;");
+ assertTrue(%HaveSameMap(strong_func, strong_func1));
gc();
})();
« src/objects.cc ('K') | « src/transitions-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698