tor-browser

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

symbol-for-index-throws.js (2698B)


      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 TypeError if index arg can not be converted to an Integer
      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  ValidateAtomicAccess( typedArray, requestIndex )
     19 
     20  2. Let accessIndex be ? ToIndex(requestIndex).
     21 
     22  ToIndex ( value )
     23 
     24  2. Else,
     25    a. Let integerIndex be ? ToInteger(value).
     26 
     27  ToInteger(value)
     28 
     29  1. Let number be ? ToNumber(argument).
     30 
     31    Symbol --> Throw a TypeError exception.
     32 
     33 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics]
     34 ---*/
     35 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     36 
     37 const i32a = new Int32Array(
     38  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     39 );
     40 
     41 const poisonedValueOf = {
     42  valueOf() {
     43    throw new Test262Error('should not evaluate this code');
     44  }
     45 };
     46 
     47 const poisonedToPrimitive = {
     48  [Symbol.toPrimitive]() {
     49    throw new Test262Error('should not evaluate this code');
     50  }
     51 };
     52 
     53 assert.throws(Test262Error, function() {
     54  Atomics.waitAsync(i32a, poisonedValueOf, poisonedValueOf, poisonedValueOf);
     55 }, '`Atomics.waitAsync(i32a, poisonedValueOf, poisonedValueOf, poisonedValueOf)` throws a Test262Error exception');
     56 
     57 assert.throws(Test262Error, function() {
     58  Atomics.waitAsync(i32a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive);
     59 }, '`Atomics.waitAsync(i32a, poisonedToPrimitive, poisonedToPrimitive, poisonedToPrimitive)` throws a Test262Error exception');
     60 
     61 assert.throws(TypeError, function() {
     62  Atomics.waitAsync(i32a, Symbol('1'), poisonedValueOf, poisonedValueOf);
     63 }, '`Atomics.waitAsync(i32a, Symbol("1"), poisonedValueOf, poisonedValueOf)` throws a TypeError exception');
     64 
     65 assert.throws(TypeError, function() {
     66  Atomics.waitAsync(i32a, Symbol('2'), poisonedToPrimitive, poisonedToPrimitive);
     67 }, '`Atomics.waitAsync(i32a, Symbol("2"), poisonedToPrimitive, poisonedToPrimitive)` throws a TypeError exception');
     68 
     69 
     70 
     71 reportCompare(0, 0);