tor-browser

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

byteoffset-is-negative-throws-sab.js (941B)


      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-dataview-buffer-byteoffset-bytelength
      8 description: >
      9  Throws a RangeError if ToInteger(byteOffset) < 0
     10 info: |
     11  24.2.2.1 DataView (buffer, byteOffset, byteLength )
     12 
     13  ...
     14  4. Let numberOffset be ? ToNumber(byteOffset).
     15  5. Let offset be ToInteger(numberOffset).
     16  6. If numberOffset ≠ offset or offset < 0, throw a RangeError exception.
     17  ...
     18 features: [SharedArrayBuffer]
     19 ---*/
     20 
     21 var ab = new SharedArrayBuffer(42);
     22 
     23 assert.throws(RangeError, function() {
     24  new DataView(ab, -1);
     25 }, "-1");
     26 
     27 assert.throws(RangeError, function() {
     28  new DataView(ab, -Infinity);
     29 }, "-Infinity");
     30 
     31 reportCompare(0, 0);