Skip to content

Commit

Permalink
Bug 1934749 [wpt PR 49486] - [shared storage] Add SharedStorageSet/Ap…
Browse files Browse the repository at this point in the history
…pend/Delete/Clear IDL Interface, a=testonly

Automatic update from web-platform-tests
[shared storage] Add SharedStorageSet/Append/Delete/Clear IDL Interface

Implement the constructor for `SharedStorageSetMethod`, etc. The
error handling logic mirrors the existing sharedStorage.set(), etc.
To allow code reuse, the sharedStorage.set(), etc. methods
now creates the object and early return on exceptions.

Note that even though we no longer explicitly call resolver->Reject()
for sharedStorage.set(), etc., Chrome still converts thrown
exceptions to rejected promises (to adhere to the specification [1]),
so the end result is the same.

This prepares for the implementation of the
`sharedStorage.batchUpdate(methods)` method, as part of the Web Lock
integration proposal:
- WICG/shared-storage#199
- WICG/shared-storage#205

[1] https://w3ctag.github.io/promises-guide/#always-return-promises

Bug: 373899210
Change-Id: Ie4edfedbe755afeb3db5ca557fd74482bac96138
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6054694
Commit-Queue: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: Cammie Smith Barnes <cammie@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1390779}

--

wpt-commits: 6a83407ba15135836db19928b90a225bf74eaa1d
wpt-pr: 49486
  • Loading branch information
yaoxiachromium authored and moz-wptsync-bot committed Dec 5, 2024
1 parent f59b434 commit 345799a
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,61 @@
return sharedStorage.delete("a");
}, 'sharedStorage.delete');

test(() => {
try {
let a = new SharedStorageSetMethod('a');
} catch (e) {
assert_equals(e.name, 'TypeError');
return;
}
assert_unreached("did not throw");
}, 'new SharedStorageSetMethod with 1 argument');

test(() => {
let a = new SharedStorageSetMethod('a', 'b');
}, 'new SharedStorageSetMethod with 2 arguments');

test(() => {
try {
let a = new SharedStorageAppendMethod('a');
} catch (e) {
assert_equals(e.name, 'TypeError');
return;
}
assert_unreached("did not throw");
}, 'new SharedStorageAppendMethod with 1 argument');

test(() => {
let a = new SharedStorageAppendMethod('a', 'b');
}, 'new SharedStorageAppendMethod with 2 arguments');

test(() => {
try {
let a = new SharedStorageDeleteMethod();
} catch (e) {
assert_equals(e.name, 'TypeError');
return;
}
assert_unreached("did not throw");
}, 'new SharedStorageDeleteMethod with no arguments');

test(() => {
let a = new SharedStorageDeleteMethod('a');
}, 'new SharedStorageDeleteMethod with 1 argument');

test(() => {
try {
let a = SharedStorageClearMethod();
} catch (e) {
assert_equals(e.name, 'TypeError');
return;
}
assert_unreached("did not throw");
}, 'call SharedStorageClearMethod() as a function');

test(() => {
let a = new SharedStorageClearMethod();
}, 'new SharedStorageClearMethod with no arguments');

</script>
</body>

0 comments on commit 345799a

Please sign in to comment.