tor-browser

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

null-for-timeout.js (1832B)


      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  null timeout arg should result in an +0 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    Null -> Return +0.
     19 
     20 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, arrow-function]
     21 ---*/
     22 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     23 
     24 const i32a = new Int32Array(
     25  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     26 );
     27 
     28 const valueOf = {
     29  valueOf() {
     30    return null;
     31  }
     32 };
     33 
     34 const toPrimitive = {
     35  [Symbol.toPrimitive]() {
     36    return null;
     37  }
     38 };
     39 
     40 assert.sameValue(
     41  Atomics.waitAsync(i32a, 0, 0, null).value,
     42  'timed-out',
     43  'The value of Atomics.waitAsync(i32a, 0, 0, null).value is "timed-out"'
     44 );
     45 assert.sameValue(
     46  Atomics.waitAsync(i32a, 0, 0, valueOf).value,
     47  'timed-out',
     48  'The value of Atomics.waitAsync(i32a, 0, 0, valueOf).value is "timed-out"'
     49 );
     50 assert.sameValue(
     51  Atomics.waitAsync(i32a, 0, 0, toPrimitive).value,
     52  'timed-out',
     53  'The value of Atomics.waitAsync(i32a, 0, 0, toPrimitive).value is "timed-out"'
     54 );
     55 
     56 reportCompare(0, 0);