-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webauthn: Update abort handling to take an abort reason
AbortController now has a `reason` [1] parameter which has been added to Web Authentication [2], Credential Management [3], and Web OTP [4]. We should update CredentialsContainer to take this `reason` to the promise then aborting a request. [1] https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/reason [2] w3c/webauthn#1706 [3] w3c/webappsec-credential-management#196 [4] WICG/web-otp#57 Bug: 1272541, 1329938 Change-Id: Idb9ef40d6a97ae240ae3a28892a426e4c0ffbfef
- Loading branch information
1 parent
ad92e64
commit d42d172
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>WebAuthn navigator.credentials.create() abort Tests</title> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src=helpers.js></script> | ||
<body></body> | ||
<script> | ||
standardSetup(function() { | ||
"use strict"; | ||
|
||
let abortController = new AbortController(); | ||
abortController.abort(); | ||
new CreateCredentialsTest("options.signal", abortController.signal) | ||
.runTest("navigator.credentials.create() abort without reason", "AbortError"); | ||
|
||
abortController = new AbortController(); | ||
abortController.abort(new Error('error')); | ||
new CreateCredentialsTest("options.signal", abortController.signal) | ||
.runTest("navigator.credentials.create() abort reason with Error", Error); | ||
}); | ||
|
||
/* JSHINT */ | ||
/* globals standardSetup, CreateCredentialsTest */ | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>WebAuthn navigator.credentials.get() abort Tests</title> | ||
<meta name="timeout" content="long"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/testdriver.js"></script> | ||
<script src="/resources/testdriver-vendor.js"></script> | ||
<script src=helpers.js></script> | ||
<body></body> | ||
<script> | ||
"use strict"; | ||
|
||
virtualAuthenticatorPromiseTest(async t => { | ||
const abortController = new AbortController(); | ||
const signal = abortController.signal; | ||
const promise = navigator.credentials.get({ | ||
publicKey: { | ||
challenge: new Uint8Array(), | ||
allowCredentials: [{ | ||
id: (await createCredential()).rawId, | ||
type: "public-key", | ||
}] | ||
}, | ||
signal: signal, | ||
}); | ||
abortController.abort(); | ||
return promise_rejects_dom(t, "AbortError", promise); | ||
}, { | ||
protocol: "ctap1/u2f", | ||
transport: "usb", | ||
}, "navigator.credentials.get() abort without reason"); | ||
|
||
virtualAuthenticatorPromiseTest(async t => { | ||
const abortController = new AbortController(); | ||
const signal = abortController.signal; | ||
const promise = navigator.credentials.get({ | ||
publicKey: { | ||
challenge: new Uint8Array(), | ||
allowCredentials: [{ | ||
id: (await createCredential()).rawId, | ||
type: "public-key", | ||
}] | ||
}, | ||
signal: signal, | ||
}); | ||
abortController.abort("CustomError"); | ||
return promise_rejects_exactly(t, "CustomError", promise); | ||
}, { | ||
protocol: "ctap1/u2f", | ||
transport: "usb", | ||
}, "navigator.credentials.get() abort reason"); | ||
|
||
virtualAuthenticatorPromiseTest(async t => { | ||
const abortController = new AbortController(); | ||
const signal = abortController.signal; | ||
const promise = navigator.credentials.get({ | ||
publicKey: { | ||
challenge: new Uint8Array(), | ||
allowCredentials: [{ | ||
id: (await createCredential()).rawId, | ||
type: "public-key", | ||
}] | ||
}, | ||
signal: signal, | ||
}); | ||
abortController.abort(new Error('error')); | ||
return promise_rejects_js(t, Error, promise); | ||
}, { | ||
protocol: "ctap1/u2f", | ||
transport: "usb", | ||
}, "navigator.credentials.get() abort reason with Error"); | ||
|
||
</script> |