From 2e31dd2bc95e31bf690bd8ecc6aeb1ec6f0ab94e Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Thu, 18 May 2023 20:21:37 +0000 Subject: [PATCH] [atomics] Add WPT for Atomics.waitAsync Bug: v8:10239 Change-Id: Ie478aed6e069d23964331fa07bfe190c55798ab3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4545947 Reviewed-by: Domenic Denicola Commit-Queue: Shu-yu Guo Cr-Commit-Position: refs/heads/main@{#1146132} --- .../atomics-wait-async.https.any.js | 25 +++++++++++++++++++ .../atomics-wait-async.https.any.js.headers | 2 ++ .../resources/notify-worker.js | 5 ++++ .../resources/notify-worker.js.headers | 1 + 4 files changed, 33 insertions(+) create mode 100644 third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js create mode 100644 third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js.headers create mode 100644 third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js create mode 100644 third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js.headers diff --git a/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js new file mode 100644 index 00000000000000..3a3ea40d773f9b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js @@ -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}`); diff --git a/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js.headers b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js.headers new file mode 100644 index 00000000000000..5f8621ef83660c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/atomics-wait-async.https.any.js.headers @@ -0,0 +1,2 @@ +Cross-Origin-Embedder-Policy: require-corp +Cross-Origin-Opener-Policy: same-origin diff --git a/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js new file mode 100644 index 00000000000000..2780e5bc34eec9 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js @@ -0,0 +1,5 @@ +onmessage = (e) => { + const sab = e.data; + const ta = new Int32Array(sab); + Atomics.notify(ta, 0); +}; diff --git a/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js.headers b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js.headers new file mode 100644 index 00000000000000..6604450991a122 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/webappapis/scripting/processing-model-2/integration-with-the-javascript-agent-formalism/resources/notify-worker.js.headers @@ -0,0 +1 @@ +Cross-Origin-Embedder-Policy: require-corp