| 1 |
// Copyright (C) 2017 Mozilla Corporation. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
esid: sec-atomics.wait |
| 6 |
description: > |
| 7 |
Test that Atomics.wait does not time out with a NaN timeout |
| 8 |
---*/ |
| 9 |
|
| 10 |
$262.agent.start( |
| 11 |
` |
| 12 |
$262.agent.receiveBroadcast(function (sab, id) { |
| 13 |
var ia = new Int32Array(sab); |
| 14 |
$262.agent.report(Atomics.wait(ia, 0, 0, NaN)); // NaN => Infinity |
| 15 |
$262.agent.leaving(); |
| 16 |
}) |
| 17 |
`); |
| 18 |
|
| 19 |
var ia = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)); |
| 20 |
|
| 21 |
$262.agent.broadcast(ia.buffer); |
| 22 |
$262.agent.sleep(500); // Ample time |
| 23 |
assert.sameValue($262.agent.getReport(), null); |
| 24 |
Atomics.wake(ia, 0); |
| 25 |
assert.sameValue(getReport(), "ok"); |
| 26 |
|
| 27 |
function getReport() { |
| 28 |
var r; |
| 29 |
while ((r = $262.agent.getReport()) == null) |
| 30 |
$262.agent.sleep(100); |
| 31 |
return r; |
| 32 |
} |