Skip to content

Commit

Permalink
[atomics] Add WPT for Atomics.waitAsync
Browse files Browse the repository at this point in the history
Bug: v8:10239
Change-Id: Ie478aed6e069d23964331fa07bfe190c55798ab3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4545947
Reviewed-by: Domenic Denicola <domenic@chromium.org>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1146132}
  • Loading branch information
syg authored and chromium-wpt-export-bot committed May 18, 2023
1 parent bc194a5 commit 195925f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// META: global=window,dedicatedworker

promise_test(async () => {
const sab = new SharedArrayBuffer(64);
const ta = new Int32Array(sab);

const waitAsyncObj = Atomics.waitAsync(ta, 0, 0, 10);
assert_equals(waitAsyncObj.async, true);
const v = await waitAsyncObj.value;
assert_equals(v, "timed-out");
}, `Atomics.waitAsync timeout in a ${self.constructor.name}`);

promise_test(async () => {
const sab = new SharedArrayBuffer(64);
const ta = new Int32Array(sab);

const waitAsyncObj = Atomics.waitAsync(ta, 0, 0);
assert_equals(waitAsyncObj.async, true);

const worker = new Worker("resources/notify-worker.js");
worker.postMessage(sab);

const v = await waitAsyncObj.value;
assert_equals(v, "ok");
}, `Atomics.waitAsync notification in a ${self.constructor.name}`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
onmessage = (e) => {
const sab = e.data;
const ta = new Int32Array(sab);
Atomics.notify(ta, 0);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cross-Origin-Embedder-Policy: require-corp

0 comments on commit 195925f

Please sign in to comment.