summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js')
-rw-r--r--testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js b/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js
new file mode 100644
index 0000000000..e317b150cc
--- /dev/null
+++ b/testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/serialization-via-idb.any.js
@@ -0,0 +1,44 @@
+// META: script=/IndexedDB/resources/support.js
+"use strict";
+
+async_test(t => {
+ const openReq = createdb(t);
+
+ openReq.onupgradeneeded = e => {
+ const db = e.target.result;
+ const store = db.createObjectStore("store", { keyPath: "key" });
+ // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
+ const sab = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;
+
+ assert_throws_dom("DataCloneError", () => {
+ store.put({ key: 1, property: sab });
+ });
+ t.done();
+ };
+}, "SharedArrayBuffer cloning via IndexedDB: basic case");
+
+async_test(t => {
+ const openReq = createdb(t);
+
+ openReq.onupgradeneeded = e => {
+ const db = e.target.result;
+ const store = db.createObjectStore("store", { keyPath: "key" });
+ // See https://github.com/whatwg/html/issues/5380 for why not `new SharedArrayBuffer()`
+ const sab = new WebAssembly.Memory({ shared:true, initial:1, maximum:1 }).buffer;
+
+ let getter1Called = false;
+ let getter2Called = false;
+
+ assert_throws_dom("DataCloneError", () => {
+ store.put({ key: 1, property: [
+ { get x() { getter1Called = true; return 5; } },
+ sab,
+ { get x() { getter2Called = true; return 5; } }
+ ]});
+ });
+
+ assert_true(getter1Called, "The getter before the SAB must have been called");
+ assert_false(getter2Called, "The getter after the SAB must not have been called");
+ t.done();
+ };
+}, "SharedArrayBuffer cloning via the IndexedDB: is interleaved correctly");