null-bufferdata-throws.js (1235B)
1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')) -- Atomics is not enabled unconditionally 2 // Copyright (C) 2018 Amal Hussein. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 esid: sec-atomics.notify 6 description: > 7 A null value for bufferData throws a TypeError 8 info: | 9 Atomics.notify( typedArray, index, count ) 10 11 1.Let buffer be ? ValidateSharedIntegerTypedArray(typedArray, true). 12 ... 13 9.If IsSharedArrayBuffer(buffer) is false, throw a TypeError exception. 14 ... 15 3.If bufferData is null, return false. 16 includes: [detachArrayBuffer.js] 17 features: [ArrayBuffer, Atomics, BigInt, TypedArray] 18 ---*/ 19 20 const i64a = new BigInt64Array( 21 new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT * 8) 22 ); 23 const poisoned = { 24 valueOf: function() { 25 throw new Test262Error('should not evaluate this code'); 26 } 27 }; 28 29 try { 30 $DETACHBUFFER(i64a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null 31 } catch (error) { 32 throw new Test262Error(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`); 33 } 34 35 assert.throws(TypeError, function() { 36 Atomics.notify(i64a, poisoned, poisoned); 37 }); 38 39 reportCompare(0, 0);