Skip to content

Commit

Permalink
Bug 1806016 [wpt PR 37535] - Web Locks: If aborted due to an AbortSig…
Browse files Browse the repository at this point in the history
…nal, use signal's reason, a=testonly

Automatic update from web-platform-tests
Web Locks: If aborted due to an AbortSignal, use signal's reason

Updated in the spec a year ago[1], if the AbortSignal has a reason,
use that as the rejection, rather than a stock AbortError w/ hardcoded
message.

The WPTs didn't cover verifying the reason for an already-aborted
signal, so add coverage for those cases too.

[1] w3c/web-locks#86

Bug: 1279877
Change-Id: I9838805b10dbb3dae0371abe41faf922344a43f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4112925
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084556}

--

wpt-commits: 9ce4a6482a088da3d74f895d8ad15c5ce0c25d28
wpt-pr: 37535
  • Loading branch information
inexorabletash authored and moz-wptsync-bot committed Dec 21, 2022
1 parent aa9e041 commit 133ebea
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions testing/web-platform/tests/web-locks/signal.tentative.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,36 @@ promise_test(async t => {
'Request should reject with AbortError');
}, 'Passing an already aborted signal aborts');

promise_test(async t => {
const res = uniqueName(t);

const controller = new AbortController();
const reason = 'My dog ate it.';
controller.abort(reason);

const promise =
navigator.locks.request(res, {signal: controller.signal},
t.unreached_func('callback should not run'));

await promise_rejects_exactly(
t, reason, promise, "Rejection should give the abort reason");
}, 'Passing an already aborted signal rejects with the custom abort reason.');

promise_test(async t => {
const res = uniqueName(t);

const controller = new AbortController();
controller.abort();

const promise =
navigator.locks.request(res, {signal: controller.signal},
t.unreached_func('callback should not run'));

await promise_rejects_exactly(
t, controller.signal.reason, promise,
"Rejection should give the abort reason");
}, 'Passing an already aborted signal rejects with the default abort reason.');

promise_test(async t => {
const res = uniqueName(t);

Expand Down

0 comments on commit 133ebea

Please sign in to comment.