tor-browser

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

non-iterable-with-thenable-awaits-once.js (686B)


      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: Non-iterable with thenables awaits each input value once without mapping callback.
      8 includes: [asyncHelpers.js]
      9 flags: [async]
     10 features: [Array.fromAsync]
     11 ---*/
     12 
     13 asyncTest(async function () {
     14  const expectedValue = {};
     15  let awaitCounter = 0;
     16  const inputThenable = {
     17    then (resolve, reject) {
     18      awaitCounter ++;
     19      resolve(expectedValue);
     20    },
     21  };
     22  const input = {
     23    length: 1,
     24    0: inputThenable,
     25  };
     26 await Array.fromAsync(input);
     27 assert.sameValue(awaitCounter, 1);
     28 });