tor-browser

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

call-construct-error.js (923B)


      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-super-keyword
      5 es6id: 12.3.5
      6 description: >
      7  Behavior when invocation of "parent" constructor returns an abrupt completion
      8 info: |
      9  [...]
     10  6. Let result be ? Construct(func, argList, newTarget).
     11 features: [class]
     12 ---*/
     13 
     14 var thrown = new Test262Error();
     15 var caught;
     16 function Parent() {
     17  throw thrown;
     18 }
     19 
     20 class Child extends Parent {
     21  constructor() {
     22    try {
     23      super();
     24    } catch (err) {
     25      caught = err;
     26    }
     27  }
     28 }
     29 
     30 // When the "construct" invocation completes and the "this" value is
     31 // uninitialized, the specification dictates that a ReferenceError must be
     32 // thrown. That behavior is tested elsewhere, so the error is ignored (if it is
     33 // produced at all).
     34 try {
     35  new Child();
     36 } catch (_) {}
     37 
     38 assert.sameValue(caught, thrown);
     39 
     40 reportCompare(0, 0);