tor-browser

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

iter-next-val-err-reject.js (1441B)


      1 // |reftest| async
      2 // Copyright (C) 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 accessing an iterator result's `value` property (rejecting
      9  promise)
     10 info: |
     11  Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
     12  If result is an abrupt completion, then
     13    If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
     14    IfAbruptRejectPromise(result, promiseCapability).
     15 
     16  ...
     17 
     18  Runtime Semantics: PerformPromiseAny
     19 
     20  ...
     21  Repeat
     22    Let nextValue be IteratorValue(next).
     23    If nextValue is an abrupt completion, set iteratorRecord.[[Done]] to true.
     24    ReturnIfAbrupt(nextValue).
     25 
     26 features: [Promise.any, Symbol.iterator]
     27 flags: [async]
     28 ---*/
     29 let callCount = 0;
     30 let error = new Test262Error();
     31 let poisoned = {
     32  done: false
     33 };
     34 Object.defineProperty(poisoned, 'value', {
     35  get() {
     36    callCount++;
     37    throw error;
     38  }
     39 });
     40 let iterNextValThrows = {
     41  [Symbol.iterator]() {
     42    callCount++;
     43    return {
     44      next() {
     45        callCount++;
     46        return poisoned;
     47      }
     48    };
     49  }
     50 };
     51 
     52 Promise.any(iterNextValThrows).then(() => {
     53  $DONE('The promise should be rejected, but was resolved');
     54 }, (reason) => {
     55  assert(error instanceof Test262Error);
     56  assert.sameValue(reason, error);
     57  assert.sameValue(callCount, 3, 'callCount === 3');
     58 }).then($DONE, $DONE);