tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

super-must-be-called.js (826B)


      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 es6id: 21.1.1
      5 description: Super need to be called to initialize internals
      6 info: |
      7  21.1.1 The String Constructor
      8 
      9  ...
     10  The String constructor is designed to be subclassable. It may be used as the
     11  value of an extends clause of a class definition. Subclass constructors that
     12  intend to inherit the specified String behaviour must include a super call to
     13  the String constructor to create and initialize the subclass instance with a
     14  [[StringData]] internal slot.
     15 ---*/
     16 
     17 class S1 extends String {
     18  constructor() {}
     19 }
     20 
     21 assert.throws(ReferenceError, function() {
     22  new S1();
     23 });
     24 
     25 class S2 extends String {
     26  constructor() {
     27    super();
     28  }
     29 }
     30 
     31 new S2();
     32 
     33 reportCompare(0, 0);