null-for-timeout.js (1848B)
1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) -- 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 null timeout arg should result in an +0 timeout 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 6. Let q be ? ToNumber(timeout). 16 17 Null -> Return +0. 18 19 features: [Atomics.waitAsync, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray, computed-property-names, Atomics, BigInt, arrow-function] 20 ---*/ 21 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); 22 const i64a = new BigInt64Array(new SharedArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); 23 24 const valueOf = { 25 valueOf() { 26 return null; 27 } 28 }; 29 30 const toPrimitive = { 31 [Symbol.toPrimitive]() { 32 return null; 33 } 34 }; 35 36 assert.sameValue( 37 Atomics.waitAsync(i64a, 0, 0n, null).value, 38 'timed-out', 39 'The value of Atomics.waitAsync(i64a, 0, 0n, null).value is "timed-out"' 40 ); 41 42 assert.sameValue( 43 Atomics.waitAsync(i64a, 0, 0n, valueOf).value, 44 'timed-out', 45 'The value of Atomics.waitAsync(i64a, 0, 0n, valueOf).value is "timed-out"' 46 ); 47 48 assert.sameValue( 49 Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value, 50 'timed-out', 51 'The value of Atomics.waitAsync(i64a, 0, 0n, toPrimitive).value is "timed-out"' 52 ); 53 54 reportCompare(0, 0);