tor-browser

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

poisoned-object-for-timeout-throws.js (1915B)


      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 esid: sec-atomics.waitasync
      6 description: >
      7  Throws a TypeError if index arg can not be converted to an Integer
      8 info: |
      9  Atomics.waitAsync( typedArray, index, value, timeout )
     10 
     11  1. Return DoWait(async, typedArray, index, value, timeout).
     12 
     13  DoWait ( mode, typedArray, index, value, timeout )
     14 
     15  6. Let q be ? ToNumber(timeout).
     16 
     17  Let primValue be ? ToPrimitive(argument, hint Number).
     18  Return ? ToNumber(primValue).
     19 
     20 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
     21 ---*/
     22 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     23 const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
     24 
     25 const poisonedValueOf = {
     26  valueOf() {
     27    throw new Test262Error('should not evaluate this code');
     28  }
     29 };
     30 
     31 const poisonedToPrimitive = {
     32  [Symbol.toPrimitive]() {
     33    throw new Test262Error('passing a poisoned object using @@ToPrimitive');
     34  }
     35 };
     36 
     37 assert.throws(Test262Error, function() {
     38  Atomics.waitAsync(i64a, 0, 0n, poisonedValueOf);
     39 }, '`Atomics.waitAsync(i64a, 0, 0n, poisonedValueOf)` throws a Test262Error exception');
     40 
     41 assert.throws(Test262Error, function() {
     42  Atomics.waitAsync(i64a, 0, 0n, poisonedToPrimitive);
     43 }, '`Atomics.waitAsync(i64a, 0, 0n, poisonedToPrimitive)` throws a Test262Error exception');
     44 
     45 reportCompare(0, 0);