| 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.wake |
| 6 |
description: > |
| 7 |
Test that Atomics.wake wakes zero waiters if the count is NaN |
| 8 |
---*/ |
| 9 |
|
| 10 |
$262.agent.start( |
| 11 |
` |
| 12 |
$262.agent.receiveBroadcast(function (sab) { |
| 13 |
var ia = new Int32Array(sab); |
| 14 |
$262.agent.report(Atomics.wait(ia, 0, 0, 1000)); // We will timeout eventually |
| 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); // Give the agent a chance to wait |
| 23 |
assert.sameValue(Atomics.wake(ia, 0, NaN), 0); // Don't actually wake it |
| 24 |
assert.sameValue(getReport(), "timed-out"); |
| 25 |
|
| 26 |
function getReport() { |
| 27 |
var r; |
| 28 |
while ((r = $262.agent.getReport()) == null) |
| 29 |
$262.agent.sleep(100); |
| 30 |
return r; |
| 31 |
} |