// Create an AbortController and abort immediately.
add_task(async function test_create_abortcontroller_and_abort() {
let ctrl = new AbortController();
ctrl.abort();
// The event shouldn't fire.
ctrl.signal.onabort = arrivingHereIsBad;
// MakeCredential() should abort immediately.
await requestMakeCredential(ctrl.signal)
.then(arrivingHereIsBad)
.catch(expectAbortError);
// GetAssertion() should abort immediately.
await requestGetAssertion(ctrl.signal)
.then(arrivingHereIsBad)
.catch(expectAbortError);
});
// Request a new credential and abort the request.
add_task(async function test_request_credential_and_abort() {
let aborted = false;
let ctrl = new AbortController();
// Request a new credential.
let request = requestMakeCredential(ctrl.signal)
.then(arrivingHereIsBad)
.catch(err => {
ok(aborted, "abort event was fired");
expectAbortError(err);
});
// Wait a tick for the statemachine to start.
await Promise.resolve();
// Abort the request.
ok(!aborted, "request still pending");
ctrl.abort();
ok(aborted, "request aborted");
// Wait for the request to terminate.
await request;
});
// Request a new assertion and abort the request.
add_task(async function test_request_assertion_and_abort() {
let aborted = false;
let ctrl = new AbortController();
// Request a new assertion.
let request = requestGetAssertion(ctrl.signal)
.then(arrivingHereIsBad)
.catch(err => {
ok(aborted, "abort event was fired");
expectAbortError(err);
});
// Wait a tick for the statemachine to start.
await Promise.resolve();
// Abort the request.
ok(!aborted, "request still pending");
ctrl.abort();
ok(aborted, "request aborted");
// Wait for the request to terminate.
await request;
});
</script>
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.