tor-browser

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

negative-length-throws.js (1061B)


      1 // |reftest| skip-if(!this.hasOwnProperty('SharedArrayBuffer')) -- SharedArrayBuffer is not enabled unconditionally
      2 // Copyright (C) 2016 The V8 Project authors. All rights reserved.
      3 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
      4 // This code is governed by the BSD license found in the LICENSE file.
      5 
      6 /*---
      7 esid: sec-sharedarraybuffer-length
      8 description: >
      9  Throws a Range Error if length represents an integer < 0
     10 info: |
     11  SharedArrayBuffer( length )
     12 
     13  1. If NewTarget is undefined, throw a TypeError exception.
     14  2. Let byteLength be ? ToIndex(length).
     15 
     16  ToIndex( value )
     17 
     18  1. If value is undefined, then
     19    a. Let index be 0.
     20  2. Else,
     21    a. Let integerIndex be ? ToInteger(value).
     22    b. If integerIndex < 0, throw a RangeError exception.
     23  ...
     24 features: [SharedArrayBuffer]
     25 ---*/
     26 
     27 assert.throws(RangeError, function() {
     28  new SharedArrayBuffer(-1);
     29 });
     30 
     31 assert.throws(RangeError, function() {
     32  new SharedArrayBuffer(-1.1);
     33 });
     34 
     35 assert.throws(RangeError, function() {
     36  new SharedArrayBuffer(-Infinity);
     37 });
     38 
     39 reportCompare(0, 0);