tor-browser

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

allocation-limit.js (1010B)


      1 // Copyright (C) 2015 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-arraybuffer-length
      6 description: >
      7  Throws a RangeError if requested Data Block is too large.
      8 info: |
      9  ArrayBuffer( length )
     10 
     11  ...
     12  6. Return AllocateArrayBuffer(NewTarget, byteLength).
     13 
     14  6.2.6.1 CreateByteDataBlock(size)
     15    ...
     16    2. Let db be a new Data Block value consisting of size bytes. If it is
     17       impossible to create such a Data Block, throw a RangeError exception.
     18    ...
     19 ---*/
     20 
     21 assert.throws(RangeError, function() {
     22  // Allocating 7 PiB should fail with a RangeError.
     23  // Math.pow(1024, 5) = 1125899906842624
     24  new ArrayBuffer(7 * 1125899906842624);
     25 }, "`length` parameter is 7 PiB");
     26 
     27 assert.throws(RangeError, function() {
     28  // Allocating almost 8 PiB should fail with a RangeError.
     29  // Math.pow(2, 53) = 9007199254740992
     30  new ArrayBuffer(9007199254740992 - 1);
     31 }, "`length` parameter is Math.pow(2, 53) - 1");
     32 
     33 reportCompare(0, 0);