tor-browser

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

negative-length-throws.js (821B)


      1 // Copyright (C) 2016 The V8 Project authors. 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 Range Error if length represents an integer < 0
      8 info: |
      9  ArrayBuffer( length )
     10 
     11  1. If NewTarget is undefined, throw a TypeError exception.
     12  2. Let byteLength be ? ToIndex(length).
     13 
     14  ToIndex( value )
     15 
     16  1. If value is undefined, then
     17    a. Let index be 0.
     18  2. Else,
     19    a. Let integerIndex be ? ToInteger(value).
     20    b. If integerIndex < 0, throw a RangeError exception.
     21  ...
     22 ---*/
     23 
     24 assert.throws(RangeError, function() {
     25  new ArrayBuffer(-1);
     26 });
     27 
     28 assert.throws(RangeError, function() {
     29  new ArrayBuffer(-1.1);
     30 });
     31 
     32 assert.throws(RangeError, function() {
     33  new ArrayBuffer(-Infinity);
     34 });
     35 
     36 reportCompare(0, 0);