tor-browser

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

iter-step-err-reject.js (1440B)


      1 // |reftest| async
      2 // Copyright (C) 2019 Leo Balter, 2020 Rick Waldron. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-promise.any
      7 description: >
      8  Error when advancing the provided iterable (rejecting promise)
      9 info: |
     10  Promise.any ( iterable )
     11 
     12  5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
     13  6. If result is an abrupt completion, then
     14    a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
     15    b. IfAbruptRejectPromise(result, promiseCapability).
     16 
     17  Runtime Semantics: PerformPromiseAny
     18 
     19  8. Repeat
     20    a. Let next be IteratorStep(iteratorRecord).
     21    b. If next is an abrupt completion, set iteratorRecord.[[done]] to true.
     22    c. ReturnIfAbrupt(next).
     23 
     24 flags: [async]
     25 features: [Promise.any, Symbol.iterator, computed-property-names, Symbol, arrow-function]
     26 ---*/
     27 
     28 let poisonedDone = {};
     29 let error = new Test262Error();
     30 Object.defineProperties(poisonedDone, {
     31  done: {
     32    get() {
     33      throw error;
     34    }
     35  },
     36  value: {
     37    get() {
     38      $DONE('The `value` property should not be accessed.');
     39    }
     40  }
     41 });
     42 let iterStepThrows = {
     43  [Symbol.iterator]() {
     44    return {
     45      next() {
     46        return poisonedDone;
     47      }
     48    };
     49  }
     50 };
     51 
     52 Promise.any(iterStepThrows).then(
     53  () => {
     54  $DONE('The promise should be rejected.');
     55 }, (reason) => {
     56  assert.sameValue(reason, error);
     57 }).then($DONE, $DONE);