tor-browser

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

false-for-timeout.js (2303B)


      1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) async -- 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  False timeout arg should result in an +0 timeout
      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 flags: [async]
     18 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, BigInt, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
     19 ---*/
     20 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     21 const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4));
     22 
     23 const valueOf = {
     24  valueOf() {
     25    return false;
     26  }
     27 };
     28 
     29 const toPrimitive = {
     30  [Symbol.toPrimitive]() {
     31    return false;
     32  }
     33 };
     34 
     35 assert.sameValue(
     36  Atomics.waitAsync(i64a, 0, 0n, false).value,
     37  'timed-out',
     38  'The value of Atomics.waitAsync(i64a, 0, 0n, false).value is "timed-out"'
     39 );
     40 
     41 assert.sameValue(
     42  Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
     43  'timed-out',
     44  'The value of Atomics.waitAsync(i64a, 0, 0n, valueOf).value is "timed-out"'
     45 );
     46 
     47 assert.sameValue(
     48  Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value,
     49  'timed-out',
     50  'The value of Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value is "timed-out"'
     51 );
     52 
     53 Promise.all([
     54  Atomics.waitAsync(i64a, 0, 0n, false).value,
     55  Atomics.waitAsync(i64a, 0, 0n, valueOf).value,
     56  Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value
     57 ]).then(outcomes => {
     58  assert.sameValue(outcomes[0], 'timed-out', 'The value of outcomes[0] is "timed-out"');
     59  assert.sameValue(outcomes[1], 'timed-out', 'The value of outcomes[1] is "timed-out"');
     60  assert.sameValue(outcomes[2], 'timed-out', 'The value of outcomes[2] is "timed-out"');
     61 }).then($DONE, $DONE);