tor-browser

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

value-not-equal.js (1936B)


      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  Returns "not-equal" when value arg does not match an index in the typedArray
      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  16. Let w be ! AtomicLoad(typedArray, i).
     17  17. If v is not equal to w, then
     18    a. Perform LeaveCriticalSection(WL).
     19    b. If mode is sync, then
     20      i. Return the String "not-equal".
     21    c. Perform ! Call(capability.[[Resolve]], undefined, « "not-equal" »).
     22    d. Return promiseCapability.[[Promise]].
     23 
     24 flags: [async]
     25 features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, computed-property-names, Symbol, Symbol.toPrimitive, Atomics, arrow-function]
     26 ---*/
     27 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"');
     28 const i32a = new Int32Array(
     29  new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4)
     30 );
     31 
     32 const valueOf = {
     33  valueOf() {
     34    return undefined;
     35  }
     36 };
     37 
     38 const toPrimitive = {
     39  [Symbol.toPrimitive]() {
     40    return undefined;
     41  }
     42 };
     43 
     44 Promise.all([
     45    Atomics.store(i32a, 0, 42),
     46    Atomics.waitAsync(i32a, 0, 0).value,
     47  ]).then(outcomes => {
     48    assert.sameValue(outcomes[0], 42, 'The value of outcomes[0] is 42');
     49    assert.sameValue(outcomes[1], 'not-equal', 'The value of outcomes[1] is "not-equal"');
     50  }).then($DONE, $DONE);