tor-browser

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

asyncitems-arraylike-too-long.js (858B)


      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  Promise is rejected if the length of the array-like to copy is out of range
      9 info: |
     10  j. If _iteratorRecord_ is not *undefined*, then
     11    ...
     12  k. Else,
     13    ...
     14    iv. If IsConstructor(_C_) is *true*, then
     15      ...
     16    v. Else,
     17      1. Let _A_ be ? ArrayCreate(_len_).
     18 
     19  ArrayCreate, step 1:
     20    1. If _length_ > 2³² - 1, throw a *RangeError* exception.
     21 includes: [asyncHelpers.js]
     22 flags: [async]
     23 features: [Array.fromAsync]
     24 ---*/
     25 
     26 asyncTest(async function () {
     27  const notConstructor = {};
     28 
     29  await assert.throwsAsync(RangeError, () => Array.fromAsync.call(notConstructor, {
     30    length: 4294967296  // 2³²
     31  }), "Array-like with excessive length");
     32 });