mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 11:37:43 -10:00
Bug 1740522 - Support abort reason on Web Locks r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D132285
This commit is contained in:
1 parent
2e54d55872
commit
1489967059
2 files changed
+35
-1
No files matched your search
@@ -98,7 +98,18 @@ IPCResult LockRequestChild::Recv__delete__(bool aAborted) {
|
||||
}
|
||||
|
||||
void LockRequestChild::RunAbortAlgorithm() {
|
||||
Recv__delete__(true);
|
||||
AutoJSAPI jsapi;
|
||||
if (NS_WARN_IF(
|
||||
!jsapi.Init(static_cast<AbortSignal*>(Signal())->GetOwnerGlobal()))) {
|
||||
mRequest.mPromise->MaybeRejectWithAbortError("The lock request is aborted");
|
||||
} else {
|
||||
JSContext* cx = jsapi.cx();
|
||||
JS::RootedValue reason(cx);
|
||||
Signal()->GetReason(cx, &reason);
|
||||
mRequest.mPromise->MaybeReject(reason);
|
||||
}
|
||||
|
||||
Unfollow();
|
||||
Send__delete__(this, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -206,3 +206,26 @@ promise_test(async t => {
|
||||
"The next request is processed after abort"
|
||||
);
|
||||
}, "Abort should process the next pending lock request");
|
||||
|
||||
promise_test(async t => {
|
||||
const res = uniqueName(t);
|
||||
|
||||
const controller = new AbortController();
|
||||
const promise = requestLockAndHold(t, res, { signal: controller.signal });
|
||||
|
||||
const reason = "My cat handled it";
|
||||
controller.abort(reason);
|
||||
|
||||
await promise_rejects_exactly(t, reason, promise, "Rejection should give the abort reason");
|
||||
}, "Aborted promise should reject with the custom abort reason");
|
||||
|
||||
promise_test(async t => {
|
||||
const res = uniqueName(t);
|
||||
|
||||
const controller = new AbortController();
|
||||
const promise = requestLockAndHold(t, res, { signal: controller.signal });
|
||||
|
||||
controller.abort();
|
||||
|
||||
await promise_rejects_exactly(t, controller.signal.reason, promise, "Should be the same reason");
|
||||
}, "Aborted promise should reject with the default abort reason");
|
||||
Reference in new issue
Block a user