tor-browser

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

out-of-range-index-throws.js (2106B)


      1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) -- SharedArrayBuffer,Atomics is not enabled unconditionally, ARM64 Simulator cannot emulate atomics, requires shell-options
      2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-atomics.waitasync
      7 description: >
      8  Throws a RangeError if value of index arg is out of range
      9 info: |
     10  Atomics.waitAsync( typedArray, index, value, timeout )
     11 
     12  1. Return DoWait(async, typedArray, index, value, timeout).
     13 
     14  DoWait ( mode, typedArray, index, value, timeout )
     15 
     16  2. Let i be ? ValidateAtomicAccess(typedArray, index).
     17 
     18    ...
     19    2.Let accessIndex be ? ToIndex(requestIndex).
     20    ...
     21    5. If accessIndex ≥ length, throw a RangeError exception.
     22 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics]
     23 ---*/
     24 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     25 const i32a = new Int32Array(
     26  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     27 );
     28 
     29 const poisoned = {
     30  valueOf() {
     31    throw new Test262Error('should not evaluate this code');
     32  }
     33 };
     34 
     35 assert.throws(RangeError, function() {
     36  Atomics.waitAsync(i32a, Infinity, poisoned, poisoned);
     37 }, '`Atomics.waitAsync(i32a, Infinity, poisoned, poisoned)` throws a RangeError exception');
     38 assert.throws(RangeError, function() {
     39  Atomics.waitAsync(i32a, -1, poisoned, poisoned);
     40 }, '`Atomics.waitAsync(i32a, -1, poisoned, poisoned)` throws a RangeError exception');
     41 assert.throws(RangeError, function() {
     42  Atomics.waitAsync(i32a, 4, poisoned, poisoned);
     43 }, '`Atomics.waitAsync(i32a, 4, poisoned, poisoned)` throws a RangeError exception');
     44 assert.throws(RangeError, function() {
     45  Atomics.waitAsync(i32a, 200, poisoned, poisoned);
     46 }, '`Atomics.waitAsync(i32a, 200, poisoned, poisoned)` throws a RangeError exception');
     47 
     48 reportCompare(0, 0);