tor-browser

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

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


      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: 22.1.1
      5 description: Super need to be called to initialize internals
      6 info: |
      7  22.1.1 The Array Constructor
      8 
      9  ...
     10 
     11  The Array constructor is designed to be subclassable. It may be used as the
     12  value of an extends clause of a class definition. Subclass constructors that
     13  intend to inherit the exotic Array behaviour must include a super call to the
     14  Array constructor to initialize subclass instances that are exotic Array
     15  objects.
     16 ---*/
     17 
     18 class A extends Array {
     19  constructor() {}
     20 }
     21 
     22 assert.throws(ReferenceError, function() {
     23  new A();
     24 });
     25 
     26 class A2 extends Array {
     27  constructor() {
     28    super();
     29  }
     30 }
     31 
     32 new A2();
     33 
     34 reportCompare(0, 0);