non-shared-bufferdata-throws.js (1615B)
1 // |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('Atomics')||!xulRuntime.shell) -- Atomics is not enabled unconditionally, 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 Throws a TypeError if typedArray.buffer is not a SharedArrayBuffer 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 1. Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true). 16 17 ValidateSharedIntegerTypedArray ( typedArray [ , waitable ] ) 18 19 5. If waitable is true, then 20 a. If typeName is not "BigInt64Array" or "BigInt64Array", throw a TypeError exception. 21 22 features: [Atomics.waitAsync, ArrayBuffer, Atomics, TypedArray, BigInt, arrow-function] 23 ---*/ 24 assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); 25 const i64a = new BigInt64Array(new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 4)); 26 27 const poisoned = { 28 valueOf() { 29 throw new Test262Error('should not evaluate this code'); 30 } 31 }; 32 33 assert.throws(TypeError, () => { 34 Atomics.waitAsync(i64a, 0, 0n, 0); 35 }, '`Atomics.waitAsync(i64a, 0, 0n, 0)` throws a TypeError exception'); 36 37 assert.throws(TypeError, () => { 38 Atomics.waitAsync(i64a, poisoned, poisoned, poisoned); 39 }, '`Atomics.waitAsync(i64a, poisoned, poisoned, poisoned)` throws a TypeError exception'); 40 41 reportCompare(0, 0);