null-bufferdata-throws.js (1308B)
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.wait 6 description: > 7 A null value for bufferData (detached) throws a TypeError 8 info: | 9 Atomics.wait( typedArray, index, value, timeout ) 10 11 Let buffer be ? ValidateIntegerTypedArray(typedArray, true). 12 ... 13 14 Let buffer be ? ValidateTypedArray(typedArray). 15 ... 16 17 If IsDetachedBuffer(buffer) is true, throw a TypeError exception. 18 ... 19 20 If arrayBuffer.[[ArrayBufferData]] is null, return true. 21 22 includes: [detachArrayBuffer.js] 23 features: [ArrayBuffer, Atomics, TypedArray] 24 ---*/ 25 26 const i32a = new Int32Array( 27 new ArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) 28 ); 29 30 const poisoned = { 31 valueOf: function() { 32 throw new Test262Error('should not evaluate this code'); 33 } 34 }; 35 36 try { 37 $DETACHBUFFER(i32a.buffer); // Detaching a non-shared ArrayBuffer sets the [[ArrayBufferData]] value to null 38 } catch (error) { 39 throw new Test262Error(`An unexpected error occurred when detaching ArrayBuffer: ${error.message}`); 40 } 41 42 assert.throws(TypeError, function() { 43 Atomics.wait(i32a, poisoned, poisoned, poisoned); 44 }); 45 46 reportCompare(0, 0);