tor-browser

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

false-for-timeout-agent.js (3245B)


      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  False 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 flags: [async]
     19 includes: [atomicsHelper.js]
     20 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, arrow-function, async-functions]
     21 ---*/
     22 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     23 
     24 const RUNNING = 1;
     25 
     26 $262.agent.start(`
     27  const valueOf = {
     28    valueOf() {
     29      return false;
     30    }
     31  };
     32 
     33  const toPrimitive = {
     34    [Symbol.toPrimitive]() {
     35      return false;
     36    }
     37  };
     38 
     39  $262.agent.receiveBroadcast(async (sab) => {
     40    const i32a = new Int32Array(sab);
     41    Atomics.add(i32a, ${RUNNING}, 1);
     42    $262.agent.report(await Atomics.waitAsync(i32a, 0, 0, false).value);
     43    $262.agent.report(await Atomics.waitAsync(i32a, 0, 0, valueOf).value);
     44    $262.agent.report(await Atomics.waitAsync(i32a, 0, 0, toPrimitive).value);
     45    $262.agent.report(Atomics.waitAsync(i32a, 0, 0, false).value);
     46    $262.agent.report(Atomics.waitAsync(i32a, 0, 0, valueOf).value);
     47    $262.agent.report(Atomics.waitAsync(i32a, 0, 0, toPrimitive).value);
     48    $262.agent.leaving();
     49  });
     50 `);
     51 
     52 const i32a = new Int32Array(
     53  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     54 );
     55 $262.agent.safeBroadcastAsync(i32a, RUNNING, 1).then(async (agentCount) => {
     56 
     57  assert.sameValue(agentCount, 1, 'The value of `agentCount` is 1');
     58 
     59  assert.sameValue(
     60    await $262.agent.getReportAsync(),
     61    'timed-out',
     62    '(await $262.agent.getReportAsync()) resolves to the value "timed-out"'
     63  );
     64  assert.sameValue(
     65    await $262.agent.getReportAsync(),
     66    'timed-out',
     67    '(await $262.agent.getReportAsync()) resolves to the value "timed-out"'
     68  );
     69  assert.sameValue(
     70    await $262.agent.getReportAsync(),
     71    'timed-out',
     72    '(await $262.agent.getReportAsync()) resolves to the value "timed-out"'
     73  );
     74  assert.sameValue(
     75    await $262.agent.getReportAsync(),
     76    'timed-out',
     77    '(await $262.agent.getReportAsync()) resolves to the value "timed-out"'
     78  );
     79  assert.sameValue(
     80    await $262.agent.getReportAsync(),
     81    'timed-out',
     82    '(await $262.agent.getReportAsync()) resolves to the value "timed-out"'
     83  );
     84  assert.sameValue(
     85    await $262.agent.getReportAsync(),
     86    'timed-out',
     87    '(await $262.agent.getReportAsync()) resolves to the value "timed-out"'
     88  );
     89 
     90  assert.sameValue(Atomics.notify(i32a, 0), 0, 'Atomics.notify(new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)), 0) must return 0');
     91 
     92 }).then($DONE, $DONE);