tor-browser

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

implicit-infinity-for-timeout.js (1497B)


      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 /*---
      6 esid: sec-atomics.waitasync
      7 description: >
      8  Undefined timeout arg should result in an infinite timeout
      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  6. Let q be ? ToNumber(timeout).
     17    ...
     18    Undefined    Return NaN.
     19 
     20  5.If q is NaN, let t be +∞, else let t be max(q, 0)
     21 
     22 flags: [async]
     23 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function]
     24 ---*/
     25 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     26 
     27 const i32a = new Int32Array(
     28  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     29 );
     30 
     31 let {async, value} = Atomics.waitAsync(i32a, 0, 0);
     32 
     33 value.then(result => {
     34 
     35  assert.sameValue(result, "ok", 'The value of `result` is "ok"');
     36 
     37 }, $DONE).then($DONE, $DONE);
     38 
     39 Atomics.notify(i32a, 0);