tor-browser

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

asyncitems-operations.js (1082B)


      1 // |reftest| async
      2 // Copyright (C) 2022 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  Array.fromAsync tries the various properties in order
      9 includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js]
     10 flags: [async]
     11 features: [Array.fromAsync]
     12 ---*/
     13 
     14 asyncTest(async function () {
     15  const actual = [];
     16  const items = {};
     17  TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items");
     18  TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items");
     19  TemporalHelpers.observeProperty(actual, items, "length", 2, "items");
     20  TemporalHelpers.observeProperty(actual, items, 0, 2, "items");
     21  TemporalHelpers.observeProperty(actual, items, 1, 1, "items");
     22  const result = await Array.fromAsync(items);
     23  assert.compareArray(result, [2, 1]);
     24  assert.compareArray(actual, [
     25    "get items[Symbol.asyncIterator]",
     26    "get items[Symbol.iterator]",
     27    "get items.length",
     28    "get items[0]",
     29    "get items[1]",
     30  ]);
     31 });