| 1 |
// |reftest| shell-option(--setpref=atomics_wait_async) skip-if(!this.hasOwnProperty('SharedArrayBuffer')||!this.hasOwnProperty('Atomics')||(this.hasOwnProperty('getBuildConfiguration')&&getBuildConfiguration('arm64-simulator'))||!xulRuntime.shell) async -- SharedArrayBuffer,Atomics is not enabled unconditionally, ARM64 Simulator cannot emulate atomics, 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 |
/*--- |
| 6 |
esid: sec-atomics.waitasync |
| 7 |
description: > |
| 8 |
Undefined timeout arg is coerced to zero |
| 9 |
info: | |
| 10 |
Atomics.waitAsync( typedArray, index, value, timeout ) |
| 11 |
|
| 12 |
1. Return DoWait(async, typedArray, index, value, timeout). |
| 13 |
|
| 14 |
DoWait ( mode, typedArray, index, value, timeout ) |
| 15 |
|
| 16 |
6. Let q be ? ToNumber(timeout). |
| 17 |
... |
| 18 |
Undefined Return NaN. |
| 19 |
|
| 20 |
5.If q is NaN, let t be +∞, else let t be max(q, 0) |
| 21 |
|
| 22 |
flags: [async] |
| 23 |
features: [Atomics.waitAsync, SharedArrayBuffer, TypedArray, Atomics, computed-property-names, Symbol, Symbol.toPrimitive, arrow-function] |
| 24 |
---*/ |
| 25 |
assert.sameValue(typeof Atomics.waitAsync, 'function', 'The value of `typeof Atomics.waitAsync` is "function"'); |
| 26 |
const i32a = new Int32Array( |
| 27 |
new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 4) |
| 28 |
); |
| 29 |
|
| 30 |
const valueOf = { |
| 31 |
valueOf() { |
| 32 |
return undefined; |
| 33 |
} |
| 34 |
}; |
| 35 |
|
| 36 |
const toPrimitive = { |
| 37 |
[Symbol.toPrimitive]() { |
| 38 |
return undefined; |
| 39 |
} |
| 40 |
}; |
| 41 |
|
| 42 |
Promise.all([ |
| 43 |
Atomics.waitAsync(i32a, 0, 0).value, |
| 44 |
Atomics.waitAsync(i32a, 0, 0, undefined).value, |
| 45 |
Atomics.waitAsync(i32a, 0, 0, valueOf).value, |
| 46 |
Atomics.waitAsync(i32a, 0, 0, toPrimitive).value |
| 47 |
]).then(outcomes => { |
| 48 |
assert.sameValue(outcomes[0], 'ok', 'The value of outcomes[0] is "ok"'); |
| 49 |
assert.sameValue(outcomes[1], 'ok', 'The value of outcomes[1] is "ok"'); |
| 50 |
assert.sameValue(outcomes[2], 'ok', 'The value of outcomes[2] is "ok"'); |
| 51 |
assert.sameValue(outcomes[3], 'ok', 'The value of outcomes[3] is "ok"'); |
| 52 |
}).then($DONE, $DONE); |
| 53 |
|
| 54 |
Atomics.notify(i32a, 0); |