retrieve-length-before-index-coercion-non-shared-detached.js (1067B)
1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally 2 // Copyright (C) 2025 André Bargull. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-atomics.notify 7 description: > 8 TypedArray length is retrieved before index parameter coercion. 9 info: | 10 25.4.15 Atomics.notify ( typedArray, index, count ) 11 ... 12 2. Let byteIndexInBuffer be ? ValidateAtomicAccess(taRecord, index). 13 ... 14 15 25.4.3.2 ValidateAtomicAccess ( taRecord, requestIndex ) 16 1. Let length be TypedArrayLength(taRecord). 17 2. Let accessIndex be ? ToIndex(requestIndex). 18 3. Assert: accessIndex ≥ 0. 19 4. If accessIndex ≥ length, throw a RangeError exception. 20 ... 21 features: [Atomics, TypedArray] 22 includes: [detachArrayBuffer.js] 23 ---*/ 24 25 var ab = new ArrayBuffer(4); 26 var ta = new Int32Array(ab); 27 28 var index = { 29 valueOf() { 30 $DETACHBUFFER(ab); 31 return 0; 32 } 33 }; 34 35 assert.sameValue(Atomics.notify(ta, index), 0); 36 37 assert.sameValue(ab.byteLength, 0); 38 39 reportCompare(0, 0);