tor-browser

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

regular-subclassing.js (1120B)


      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: 25.4.3
      5 description: Subclassing the Promise object
      6 info: |
      7  25.4.3 The Promise Constructor
      8 
      9  ...
     10 
     11  The Promise constructor is designed to be subclassable. It may be used as the
     12  value in an extends clause of a class definition. Subclass constructors that
     13  intend to inherit the specified Promise behaviour must include a super call
     14  to the Promise constructor to create and initialize the subclass instance with
     15  the internal state necessary to support the Promise and Promise.prototype
     16  built-in methods.
     17 ---*/
     18 
     19 class Prom extends Promise {}
     20 
     21 assert.throws(TypeError, function() {
     22  new Prom();
     23 });
     24 
     25 var calledExecutor = false;
     26 var executorArguments;
     27 
     28 var prom1 = new Prom(function() {
     29  calledExecutor = true;
     30  executorArguments = arguments;
     31 });
     32 
     33 assert(calledExecutor);
     34 assert.sameValue(executorArguments.length, 2);
     35 assert.sameValue(typeof executorArguments[0], "function");
     36 assert.sameValue(typeof executorArguments[1], "function");
     37 
     38 reportCompare(0, 0);