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