symbol-for-index-throws.js (1836B)
1 // |reftest| skip-if(!this.hasOwnProperty('Atomics')||!this.hasOwnProperty('SharedArrayBuffer')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))) -- Atomics,SharedArrayBuffer is not enabled unconditionally, ARM64 Simulator cannot emulate atomics 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 /*--- 6 esid: sec-atomics.notify 7 description: > 8 Return abrupt when ToInteger throws for 'index' argument to Atomics.notify 9 info: | 10 Atomics.notify( typedArray, index, value, timeout ) 11 12 2. Let i be ? ValidateAtomicAccess(typedArray, index). 13 14 ValidateAtomicAccess( typedArray, requestIndex ) 15 16 2. Let accessIndex be ? ToIndex(requestIndex). 17 18 ToIndex ( value ) 19 20 2. Else, 21 a. Let integerIndex be ? ToInteger(value). 22 23 ToInteger(value) 24 25 1. Let number be ? ToNumber(argument). 26 27 Symbol --> Throw a TypeError exception. 28 29 features: [Atomics, SharedArrayBuffer, Symbol, Symbol.toPrimitive, TypedArray] 30 ---*/ 31 32 const i32a = new Int32Array( 33 new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) 34 ); 35 36 const poisonedValueOf = { 37 valueOf: function() { 38 throw new Test262Error('should not evaluate this code'); 39 } 40 }; 41 42 const poisonedToPrimitive = { 43 [Symbol.toPrimitive]: function() { 44 throw new Test262Error("passing a poisoned object using @@ToPrimitive"); 45 } 46 }; 47 48 assert.throws(Test262Error, function() { 49 Atomics.notify(i32a, poisonedValueOf, poisonedValueOf); 50 }); 51 52 assert.throws(Test262Error, function() { 53 Atomics.notify(i32a, poisonedToPrimitive, poisonedToPrimitive); 54 }); 55 56 assert.throws(TypeError, function() { 57 Atomics.notify(i32a, Symbol("foo"), poisonedValueOf); 58 }); 59 60 assert.throws(TypeError, function() { 61 Atomics.notify(i32a, Symbol("foo"), poisonedToPrimitive); 62 }); 63 64 reportCompare(0, 0);