tor-browser

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

resolve-element-function-nonconstructor.js (1038B)


      1 // Copyright (C) 2019 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-promise.allsettled-resolve-element-functions
      6 description: Promise.allSettled Resolve Element functions are not constructors
      7 info: |
      8  17 ECMAScript Standard Built-in Objects:
      9    Built-in function objects that are not identified as constructors do not
     10    implement the [[Construct]] internal method unless otherwise specified
     11    in the description of a particular function.
     12 features: [Promise.allSettled]
     13 ---*/
     14 
     15 var resolveElementFunction;
     16 var thenable = {
     17  then(fulfill) {
     18    resolveElementFunction = fulfill;
     19  }
     20 };
     21 
     22 function NotPromise(executor) {
     23  executor(function() {}, function() {});
     24 }
     25 NotPromise.resolve = function(v) {
     26  return v;
     27 };
     28 Promise.allSettled.call(NotPromise, [thenable]);
     29 
     30 assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, 'prototype'), false);
     31 assert.throws(TypeError, function() {
     32  new resolveElementFunction();
     33 });
     34 
     35 reportCompare(0, 0);