tor-browser

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

nan-for-timeout.js (1536B)


      1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics
      2 // Copyright (C) 2018 Amal Hussein.  All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-atomics.wait
      7 description: >
      8  NaN timeout arg should result in an infinite timeout
      9 info: |
     10  Atomics.wait( typedArray, index, value, timeout )
     11 
     12  4.Let q be ? ToNumber(timeout).
     13    ...
     14    Undefined    Return NaN.
     15  5.If q is NaN, let t be +∞, else let t be max(q, 0)
     16 
     17 includes: [atomicsHelper.js]
     18 features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
     19 ---*/
     20 
     21 const i64a = new BigInt64Array(
     22  new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
     23 );
     24 
     25 const RUNNING = 1;
     26 
     27 $262.agent.start(`
     28  $262.agent.receiveBroadcast(function(sab) {
     29    const i64a = new BigInt64Array(sab);
     30    Atomics.add(i64a, ${RUNNING}, 1n);
     31 
     32    $262.agent.report(Atomics.wait(i64a, 0, 0n, NaN));  // NaN => +Infinity
     33    $262.agent.leaving();
     34  });
     35 `);
     36 
     37 $262.agent.safeBroadcast(i64a);
     38 $262.agent.waitUntil(i64a, RUNNING, 1n);
     39 
     40 // Try to yield control to ensure the agent actually started to wait.
     41 $262.agent.tryYield();
     42 
     43 assert.sameValue(Atomics.notify(i64a, 0), 1, 'Atomics.notify(i64a, 0) returns 1');
     44 assert.sameValue($262.agent.getReport(), 'ok', '$262.agent.getReport() returns "ok"');
     45 
     46 reportCompare(0, 0);