From df1d7ed7c48cd3b2f4ce15a7ed660da0b3f3fd48 Mon Sep 17 00:00:00 2001
From: Yao Xiao
Date: Thu, 5 Dec 2024 22:34:52 +0000
Subject: [PATCH] Bug 1935267 [wpt PR 49533] - [shared storage] Implement
batchUpdate() for Window and SharedStorageWorklet context, a=testonly
Automatic update from web-platform-tests
[shared storage] Implement batchUpdate() for Window and SharedStorageWorklet context
This allows developers to perform multiple Shared Storage operations
atomically within a single lock, as part of the Web Lock integration
proposal:
- https://github.com/WICG/shared-storage/pull/199
- https://github.com/WICG/shared-storage/pull/205
How:
- Add `batchUpdate(methods, options)` to the `SharedStorage` interface.
- Hooks up the `batchUpdate()` method to the
`SharedStorageLockManager::SharedStorageBatchUpdate()` API in the
browser process.
Bug: 373899210
Fuchsia-Binary-Size: Size increase is unavoidable.
Change-Id: I0e1b355e3b3d28518396ae4333afe21e6d02e858
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6069087
Reviewed-by: Ayu Ishii
Commit-Queue: Yao Xiao
Cr-Commit-Position: refs/heads/main@{#1391933}
--
wpt-commits: d54d933593b96018172d332ece95dcec9839a059
wpt-pr: 49533
---
.../shared-storage/resources/simple-module.js | 15 ++++
.../setters.tentative.https.sub.html | 17 ++++
...ndow-batch-update.tentative.https.sub.html | 74 ++++++++++++++++
...klet-batch-update.tentative.https.sub.html | 85 +++++++++++++++++++
4 files changed, 191 insertions(+)
create mode 100644 testing/web-platform/tests/shared-storage/web-locks-window-batch-update.tentative.https.sub.html
create mode 100644 testing/web-platform/tests/shared-storage/web-locks-worklet-batch-update.tentative.https.sub.html
diff --git a/testing/web-platform/tests/shared-storage/resources/simple-module.js b/testing/web-platform/tests/shared-storage/resources/simple-module.js
index 80689e5f9d3f..4bd7085256e1 100644
--- a/testing/web-platform/tests/shared-storage/resources/simple-module.js
+++ b/testing/web-platform/tests/shared-storage/resources/simple-module.js
@@ -155,6 +155,20 @@ class AppendWithLockOptionOperation {
}
}
+class BatchUpdateWithTwoAppendMethodsWithBatchLockOptionOperation {
+ async run(urls, data) {
+ if (data && data.hasOwnProperty('key') && data.hasOwnProperty('lock_name')
+ && data.hasOwnProperty('append_letter')) {
+ sharedStorage.batchUpdate([
+ new SharedStorageAppendMethod(data['key'], data['append_letter']),
+ new SharedStorageAppendMethod(data['key'], data['append_letter'])
+ ], {withLock: data['lock_name']});
+ return 1;
+ }
+ return -1;
+ }
+}
+
register('test-url-selection-operation', TestURLSelectionOperation);
register('test-url-selection-operation-2', TestURLSelectionOperationTwo);
register('test-slow-url-selection-operation', TestSlowURLSelectionOperation);
@@ -166,3 +180,4 @@ register('verify-interest-groups', VerifyInterestGroups);
register('get-wait-increment-within-lock', GetWaitIncrementWithinLockOperation);
register('get-wait-set-within-lock', GetWaitSetWithinLockOperation);
register('append-with-lock-option', AppendWithLockOptionOperation);
+register('batch-update-with-two-append-methods-with-batch-lock-option', BatchUpdateWithTwoAppendMethodsWithBatchLockOptionOperation);
diff --git a/testing/web-platform/tests/shared-storage/setters.tentative.https.sub.html b/testing/web-platform/tests/shared-storage/setters.tentative.https.sub.html
index 35462f3b2abb..c5380f8dd856 100644
--- a/testing/web-platform/tests/shared-storage/setters.tentative.https.sub.html
+++ b/testing/web-platform/tests/shared-storage/setters.tentative.https.sub.html
@@ -104,5 +104,22 @@
let a = new SharedStorageClearMethod();
}, 'new SharedStorageClearMethod with no arguments');
+promise_test(() => {
+ return sharedStorage.batchUpdate([
+ new SharedStorageSetMethod("key0", "value0", {withLock: "lock1"}),
+ new SharedStorageAppendMethod("key1", "value1"),
+ new SharedStorageDeleteMethod("key2"),
+ new SharedStorageClearMethod({withLock: "lock2"})
+ ], {withLock: "lock3"});
+}, 'sharedStorage.batchUpdate');
+
+promise_test(async t => {
+ return promise_rejects_js(t, TypeError, sharedStorage.batchUpdate());
+}, 'sharedStorage.batchUpdate without \'methods\' argument');
+
+promise_test(async t => {
+ return promise_rejects_js(t, TypeError, sharedStorage.batchUpdate(["123"]));
+}, 'sharedStorage.batchUpdate with invalid \'methods\' argument');
+
+
+
+
+