Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1 | // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | "use strict"; |
| 6 | var realm = Realm.create(); |
| 7 | var OtherTypeError = Realm.eval(realm, 'TypeError'); |
| 8 | |
| 9 | class Derived extends Object { |
| 10 | constructor() { |
| 11 | return null; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | assertThrows(() => { new Derived() }, TypeError); |
| 16 | |
| 17 | var OtherDerived = Realm.eval(realm, |
| 18 | "'use strict';" + |
| 19 | "class Derived extends Object {" + |
| 20 | "constructor() {" + |
| 21 | "return null;" + |
| 22 | "}};"); |
| 23 | |
| 24 | // Before throwing the TypeError we have to switch to the caller context. |
| 25 | assertThrows(() => { new OtherDerived() }, TypeError); |