tor-browser

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

sync-iterable-with-thenable-awaits-once.js (675B)


      1 // |reftest| async
      2 // Copyright (C) 2023 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-array.fromasync
      7 description: >
      8  Sync-iterable input with thenables awaits each input once without mapping callback
      9 includes: [asyncHelpers.js]
     10 flags: [async]
     11 features: [Array.fromAsync]
     12 ---*/
     13 
     14 asyncTest(async function () {
     15  const expectedValue = {};
     16  let awaitCounter = 0;
     17  const inputThenable = {
     18    then (resolve, reject) {
     19      awaitCounter++;
     20      resolve(expectedValue);
     21    },
     22  };
     23  const input = [ inputThenable ].values();
     24  await Array.fromAsync(input);
     25  assert.sameValue(awaitCounter, 1);
     26 });