tor-browser

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

exception-after-resolve-in-thenable-job.js (1053B)


      1 // |reftest| async
      2 // Copyright (C) 2015 André Bargull. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 es6id: 25.4.2.2
      7 description: >
      8  Already resolved promise is not rejected when then() function throws an exception.
      9 info: |
     10  PromiseResolveThenableJob ( promiseToResolve, thenable, then )
     11 
     12  1. Let resolvingFunctions be CreateResolvingFunctions(promiseToResolve).
     13  2. Let thenCallResult be Call(then, thenable, «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
     14  3. If thenCallResult is an abrupt completion,
     15    a. Let status be Call(resolvingFunctions.[[Reject]], undefined, «thenCallResult.[[value]]»)
     16    b. NextJob Completion(status).
     17  ...
     18 flags: [async]
     19 ---*/
     20 
     21 var thenable = {
     22  then: function(resolve) {
     23    resolve();
     24  }
     25 };
     26 
     27 var thenableWithError = {
     28  then: function(resolve) {
     29    resolve(thenable);
     30    throw new Error("ignored exception");
     31  }
     32 };
     33 
     34 function executor(resolve, reject) {
     35  resolve(thenableWithError);
     36 }
     37 
     38 new Promise(executor).then($DONE, $DONE);