derived-this-uninitialized-realm.js (778B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget 5 description: > 6 Error when derived constructor does not initialize the `this` binding 7 (honoring the Realm of the current execution context) 8 info: | 9 [...] 10 15. Return ? envRec.GetThisBinding(). 11 12 8.1.1.3.4 GetThisBinding () 13 14 [...] 15 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError 16 exception. 17 features: [cross-realm, class] 18 ---*/ 19 20 var C = $262.createRealm().global.eval( 21 '(class C extends Object {' + 22 ' constructor() {}' + 23 '});' 24 ); 25 26 assert.throws(ReferenceError, function() { 27 new C(); 28 }); 29 30 reportCompare(0, 0);