Index: test/mjsunit/es6/classes.js |
diff --git a/test/mjsunit/es6/classes.js b/test/mjsunit/es6/classes.js |
index a1420be1c2d6c582f44bc069a310cd7dc36144d7..54cd1651566c3094f86f09d297f611d2c9e11ed2 100644 |
--- a/test/mjsunit/es6/classes.js |
+++ b/test/mjsunit/es6/classes.js |
@@ -625,6 +625,31 @@ function assertAccessorDescriptor(object, name) { |
assertTrue(new C(1) instanceof C); |
})(); |
+(function TestConstructorCall(){ |
+ var realmIndex = Realm.create(); |
+ var otherTypeError = Realm.eval(realmIndex, "TypeError"); |
+ var A = Realm.eval(realmIndex, '"use strict"; class A {}'); |
+ var instance = new A(); |
+ var constructor = instance.constructor; |
+ var otherTypeError = Realm.eval(realmIndex, 'TypeError'); |
+ if (otherTypeError === TypeError) { |
+ throw Error('Should not happen!'); |
+ } |
+ |
+ // ES6 9.2.1[[Call]] throws a TypeError in the caller context/Realm when the |
+ // called function is a classConstructor |
+ assertThrows(function() { Realm.eval(realmIndex, "A()") }, otherTypeError); |
+ assertThrows(function() { instance.constructor() }, TypeError); |
+ assertThrows(function() { A() }, TypeError); |
+ |
+ // ES6 9.3.1 call() first activates the callee context before invoking the |
+ // method. The TypeError from the constructor is thus thrown in the other |
+ // Realm. |
+ assertThrows(function() { Realm.eval(realmIndex, "A.call()") }, |
+ otherTypeError); |
+ assertThrows(function() { constructor.call() }, otherTypeError); |
+ assertThrows(function() { A.call() }, otherTypeError); |
+})(); |
(function TestDefaultConstructor() { |
var calls = 0; |