| 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 arg is not an Object |
| 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 |
2. Perform ? RequireInternalSlot(typedArray, [[TypedArrayName]]). |
| 20 |
|
| 21 |
RequireInternalSlot ( O, internalSlot ) |
| 22 |
|
| 23 |
1. If Type(O) is not Object, throw a TypeError exception. |
| 24 |
2. If O does not have an internalSlot internal slot, throw a TypeError exception. |
| 25 |
|
| 26 |
features: [Atomics.waitAsync, Symbol, arrow-function, Atomics] |
| 27 |
---*/ |
| 28 |
assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); |
| 29 |
const poisoned = { |
| 30 |
valueOf() { |
| 31 |
throw new Test262Error('should not evaluate this code'); |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
assert.throws(TypeError, () => { |
| 36 |
Atomics.waitAsync(null, poisoned, poisoned, poisoned); |
| 37 |
}, '`Atomics.waitAsync(null, poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 38 |
|
| 39 |
assert.throws(TypeError, () => { |
| 40 |
Atomics.waitAsync(undefined, poisoned, poisoned, poisoned); |
| 41 |
}, '`Atomics.waitAsync(undefined, poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 42 |
|
| 43 |
assert.throws(TypeError, () => { |
| 44 |
Atomics.waitAsync(true, poisoned, poisoned, poisoned); |
| 45 |
}, '`Atomics.waitAsync(true, poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 46 |
|
| 47 |
assert.throws(TypeError, () => { |
| 48 |
Atomics.waitAsync(false, poisoned, poisoned, poisoned); |
| 49 |
}, '`Atomics.waitAsync(false, poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 50 |
|
| 51 |
assert.throws(TypeError, () => { |
| 52 |
Atomics.waitAsync('***string***', poisoned, poisoned, poisoned); |
| 53 |
}, '`Atomics.waitAsync("***string***", poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 54 |
|
| 55 |
assert.throws(TypeError, () => { |
| 56 |
Atomics.waitAsync(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned); |
| 57 |
}, '`Atomics.waitAsync(Number.NEGATIVE_INFINITY, poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 58 |
|
| 59 |
assert.throws(TypeError, () => { |
| 60 |
Atomics.waitAsync(Symbol('***symbol***'), poisoned, poisoned, poisoned); |
| 61 |
}, '`Atomics.waitAsync(Symbol("***symbol***"), poisoned, poisoned, poisoned)` throws a TypeError exception'); |
| 62 |
|
| 63 |
|
| 64 |
reportCompare(0, 0); |