tor-browser

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

reject-via-abrupt-queue.js (1593B)


      1 // |reftest| async
      2 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 description: >
      7  Rejecting through an abrupt completion - captured in a queued job
      8 esid: sec-promise-executor
      9 info: |
     10  25.4.3.1 Promise ( executor )
     11 
     12  ...
     13  9. Let completion be Call(executor, undefined, « resolvingFunctions.[[Resolve]],
     14    resolvingFunctions.[[Reject]] »).
     15  10. If completion is an abrupt completion, then
     16    a. Perform ? Call(resolvingFunctions.[[Reject]], undefined, « completion.[[Value]] »).
     17  11. Return promise.
     18 
     19  25.4.1.3.1 Promise Reject Functions
     20 
     21  ...
     22  6. Return RejectPromise(promise, reason).
     23 
     24  25.4.5.3.1 PerformPromiseThen ( promise, onFulfilled, onRejected, resultCapability )
     25 
     26  ...
     27  4. If IsCallable(onRejected) is false, then
     28    a. Set onRejected to undefined.
     29  ...
     30  6. Let rejectReaction be the PromiseReaction { [[Capability]]: resultCapability,
     31    [[Type]]: "Reject", [[Handler]]: onRejected }.
     32  ...
     33  9. Else,
     34    a. Assert: The value of promise.[[PromiseState]] is "rejected".
     35    ...
     36    d. Perform EnqueueJob("PromiseJobs", PromiseReactionJob, « rejectReaction, reason »).
     37 flags: [async]
     38 ---*/
     39 
     40 var thenable = Promise.resolve();
     41 var p = new Promise(function() {
     42  throw thenable;
     43 });
     44 
     45 p.then(function() {
     46  $DONE('The promise should not be fulfilled.');
     47 }).then(function() {
     48  $DONE('The promise should not be fulfilled.');
     49 }, function(x) {
     50  if (x !== thenable) {
     51    $DONE('The promise should be rejected with the resolution value.');
     52    return;
     53  }
     54  $DONE();
     55 });