tor-browser

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

value-not-equal.js (1883B)


      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  Returns "not-equal" when value arg does not match an index in the typedArray
      9 info: |
     10  Atomics.wait( typedArray, index, value, timeout )
     11 
     12  3.Let v be ? ToBigInt64(value).
     13    ...
     14  14.If v is not equal to w, then
     15    a.Perform LeaveCriticalSection(WL).
     16    b. Return the String "not-equal".
     17 
     18 includes: [atomicsHelper.js]
     19 features: [Atomics, BigInt, SharedArrayBuffer, TypedArray]
     20 ---*/
     21 
     22 const RUNNING = 1;
     23 const value = "42n";
     24 
     25 const i64a = new BigInt64Array(
     26  new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)
     27 );
     28 
     29 $262.agent.start(`
     30  $262.agent.receiveBroadcast(function(sab) {
     31    const i64a = new BigInt64Array(sab);
     32    Atomics.add(i64a, ${RUNNING}, 1n);
     33 
     34    $262.agent.report(Atomics.store(i64a, 0, ${value}));
     35    $262.agent.report(Atomics.wait(i64a, 0, 0n));
     36    $262.agent.leaving();
     37  });
     38 `);
     39 
     40 // NB: We don't actually explicitly need to wait for the agent to start in this
     41 // test case, we only do it for consistency with other test cases which do
     42 // require the main agent to wait and yield control.
     43 
     44 $262.agent.safeBroadcast(i64a);
     45 $262.agent.waitUntil(i64a, RUNNING, 1n);
     46 
     47 // Try to yield control to ensure the agent actually started to wait.
     48 $262.agent.tryYield();
     49 
     50 assert.sameValue(
     51  $262.agent.getReport(),
     52  '42',
     53  '$262.agent.getReport() returns "42"'
     54 );
     55 assert.sameValue(
     56  $262.agent.getReport(),
     57  'not-equal',
     58  '$262.agent.getReport() returns "not-equal"'
     59 );
     60 
     61 
     62 reportCompare(0, 0);