tor-browser

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

symbol-for-timeout-throws.js (2214B)


      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    Symbol --> Throw a TypeError exception.
     18 
     19 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt]
     20 ---*/
     21 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     22 const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
     23 
     24 const poisonedValueOf = {
     25  valueOf() {
     26    throw new Test262Error('should not evaluate this code');
     27  }
     28 };
     29 
     30 const poisonedToPrimitive = {
     31  [Symbol.toPrimitive]() {
     32    throw new Test262Error('passing a poisoned object using @@ToPrimitive');
     33  }
     34 };
     35 
     36 assert.throws(Test262Error, function() {
     37  Atomics.waitAsync(i64a, 0, 0n, poisonedValueOf);
     38 }, '`Atomics.waitAsync(i64a, 0, 0n, poisonedValueOf)` throws a Test262Error exception');
     39 
     40 assert.throws(Test262Error, function() {
     41  Atomics.waitAsync(i64a, 0, 0n, poisonedToPrimitive);
     42 }, '`Atomics.waitAsync(i64a, 0, 0n, poisonedToPrimitive)` throws a Test262Error exception');
     43 
     44 assert.throws(TypeError, function() {
     45  Atomics.waitAsync(i64a, 0, 0n, Symbol('foo'));
     46 }, '`Atomics.waitAsync(i64a, 0, 0n, Symbol("foo"))` throws a TypeError exception');
     47 
     48 assert.throws(TypeError, function() {
     49  Atomics.waitAsync(i64a, 0, 0n, Symbol('foo'));
     50 }, '`Atomics.waitAsync(i64a, 0, 0n, Symbol("foo"))` throws a TypeError exception');
     51 
     52 reportCompare(0, 0);