forked from mirrors/gecko-dev
Backed out changeset 8a85807aac36 (bug 1857982) for wpt failure on enrollment.https.html . CLOSED TREE
This commit is contained in:
parent
70ac30a0b5
commit
ca9c76ff42
4 changed files with 57 additions and 79 deletions
|
|
@ -177,7 +177,7 @@ nsresult RelaxSameOrigin(nsPIDOMWindowInner* aParent,
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
void WebAuthnManager::ClearTransaction() {
|
void WebAuthnManager::ClearTransaction() {
|
||||||
if (mTransaction.isSome()) {
|
if (!mTransaction.isNothing()) {
|
||||||
StopListeningForVisibilityEvents();
|
StopListeningForVisibilityEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -185,10 +185,20 @@ void WebAuthnManager::ClearTransaction() {
|
||||||
Unfollow();
|
Unfollow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAuthnManager::CancelParent() {
|
void WebAuthnManager::RejectTransaction(const nsresult& aError) {
|
||||||
|
if (!NS_WARN_IF(mTransaction.isNothing())) {
|
||||||
|
mTransaction.ref().mPromise->MaybeReject(aError);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebAuthnManager::CancelTransaction(const nsresult& aError) {
|
||||||
if (!NS_WARN_IF(!mChild || mTransaction.isNothing())) {
|
if (!NS_WARN_IF(!mChild || mTransaction.isNothing())) {
|
||||||
mChild->SendRequestCancel(mTransaction.ref().mId);
|
mChild->SendRequestCancel(mTransaction.ref().mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RejectTransaction(aError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAuthnManager::HandleVisibilityChange() {
|
void WebAuthnManager::HandleVisibilityChange() {
|
||||||
|
|
@ -234,7 +244,13 @@ already_AddRefed<Promise> WebAuthnManager::MakeCredential(
|
||||||
|
|
||||||
// Otherwise, the user may well have clicked away, so let's
|
// Otherwise, the user may well have clicked away, so let's
|
||||||
// abort the old transaction and take over control from here.
|
// abort the old transaction and take over control from here.
|
||||||
CancelTransaction(NS_ERROR_DOM_ABORT_ERR);
|
CancelTransaction(NS_ERROR_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abort the request if aborted flag is already set.
|
||||||
|
if (aSignal.WasPassed() && aSignal.Value().Aborted()) {
|
||||||
|
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||||
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString origin;
|
nsString origin;
|
||||||
|
|
@ -436,30 +452,11 @@ already_AddRefed<Promise> WebAuthnManager::MakeCredential(
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort the request if aborted flag is already set.
|
|
||||||
if (aSignal.WasPassed() && aSignal.Value().Aborted()) {
|
|
||||||
AutoJSAPI jsapi;
|
|
||||||
if (!jsapi.Init(global)) {
|
|
||||||
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
|
||||||
return promise.forget();
|
|
||||||
}
|
|
||||||
JSContext* cx = jsapi.cx();
|
|
||||||
JS::Rooted<JS::Value> reason(cx);
|
|
||||||
aSignal.Value().GetReason(cx, &reason);
|
|
||||||
promise->MaybeReject(reason);
|
|
||||||
return promise.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
WebAuthnMakeCredentialInfo info(
|
WebAuthnMakeCredentialInfo info(
|
||||||
origin, NS_ConvertUTF8toUTF16(rpId), challenge, clientDataJSON,
|
origin, NS_ConvertUTF8toUTF16(rpId), challenge, clientDataJSON,
|
||||||
adjustedTimeout, excludeList, rpInfo, userInfo, coseAlgos, extensions,
|
adjustedTimeout, excludeList, rpInfo, userInfo, coseAlgos, extensions,
|
||||||
authSelection, attestation, context->Top()->Id());
|
authSelection, attestation, context->Top()->Id());
|
||||||
|
|
||||||
// Set up the transaction state (including event listeners, etc). Fallible
|
|
||||||
// operations should not be performed below this line, as we must not leave
|
|
||||||
// the transaction state partially initialized. Once the transaction state is
|
|
||||||
// initialized the only valid ways to end the transaction are
|
|
||||||
// CancelTransaction, RejectTransaction, and FinishMakeCredential.
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if (!WinWebAuthnManager::AreWebAuthNApisAvailable()) {
|
if (!WinWebAuthnManager::AreWebAuthNApisAvailable()) {
|
||||||
ListenForVisibilityEvents();
|
ListenForVisibilityEvents();
|
||||||
|
|
@ -506,7 +503,13 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||||
|
|
||||||
// Otherwise, the user may well have clicked away, so let's
|
// Otherwise, the user may well have clicked away, so let's
|
||||||
// abort the old transaction and take over control from here.
|
// abort the old transaction and take over control from here.
|
||||||
CancelTransaction(NS_ERROR_DOM_ABORT_ERR);
|
CancelTransaction(NS_ERROR_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abort the request if aborted flag is already set.
|
||||||
|
if (aSignal.WasPassed() && aSignal.Value().Aborted()) {
|
||||||
|
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
||||||
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString origin;
|
nsString origin;
|
||||||
|
|
@ -653,30 +656,11 @@ already_AddRefed<Promise> WebAuthnManager::GetAssertion(
|
||||||
return promise.forget();
|
return promise.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort the request if aborted flag is already set.
|
|
||||||
if (aSignal.WasPassed() && aSignal.Value().Aborted()) {
|
|
||||||
AutoJSAPI jsapi;
|
|
||||||
if (!jsapi.Init(global)) {
|
|
||||||
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
|
|
||||||
return promise.forget();
|
|
||||||
}
|
|
||||||
JSContext* cx = jsapi.cx();
|
|
||||||
JS::Rooted<JS::Value> reason(cx);
|
|
||||||
aSignal.Value().GetReason(cx, &reason);
|
|
||||||
promise->MaybeReject(reason);
|
|
||||||
return promise.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
WebAuthnGetAssertionInfo info(origin, NS_ConvertUTF8toUTF16(rpId), challenge,
|
WebAuthnGetAssertionInfo info(origin, NS_ConvertUTF8toUTF16(rpId), challenge,
|
||||||
clientDataJSON, adjustedTimeout, allowList,
|
clientDataJSON, adjustedTimeout, allowList,
|
||||||
extensions, aOptions.mUserVerification,
|
extensions, aOptions.mUserVerification,
|
||||||
context->Top()->Id());
|
context->Top()->Id());
|
||||||
|
|
||||||
// Set up the transaction state (including event listeners, etc). Fallible
|
|
||||||
// operations should not be performed below this line, as we must not leave
|
|
||||||
// the transaction state partially initialized. Once the transaction state is
|
|
||||||
// initialized the only valid ways to end the transaction are
|
|
||||||
// CancelTransaction, RejectTransaction, and FinishGetAssertion.
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if (!WinWebAuthnManager::AreWebAuthNApisAvailable()) {
|
if (!WinWebAuthnManager::AreWebAuthNApisAvailable()) {
|
||||||
ListenForVisibilityEvents();
|
ListenForVisibilityEvents();
|
||||||
|
|
@ -720,7 +704,7 @@ already_AddRefed<Promise> WebAuthnManager::Store(const Credential& aCredential,
|
||||||
|
|
||||||
// Otherwise, the user may well have clicked away, so let's
|
// Otherwise, the user may well have clicked away, so let's
|
||||||
// abort the old transaction and take over control from here.
|
// abort the old transaction and take over control from here.
|
||||||
CancelTransaction(NS_ERROR_DOM_ABORT_ERR);
|
CancelTransaction(NS_ERROR_ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
promise->MaybeReject(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||||
|
|
@ -838,21 +822,7 @@ void WebAuthnManager::RequestAborted(const uint64_t& aTransactionId,
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAuthnManager::RunAbortAlgorithm() {
|
void WebAuthnManager::RunAbortAlgorithm() {
|
||||||
if (NS_WARN_IF(mTransaction.isNothing())) {
|
CancelTransaction(NS_ERROR_DOM_ABORT_ERR);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mParent);
|
|
||||||
|
|
||||||
AutoJSAPI jsapi;
|
|
||||||
if (!jsapi.Init(global)) {
|
|
||||||
CancelTransaction(NS_ERROR_DOM_ABORT_ERR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JSContext* cx = jsapi.cx();
|
|
||||||
JS::Rooted<JS::Value> reason(cx);
|
|
||||||
Signal()->GetReason(cx, &reason);
|
|
||||||
CancelTransaction(reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mozilla::dom
|
} // namespace mozilla::dom
|
||||||
|
|
|
||||||
|
|
@ -112,33 +112,17 @@ class WebAuthnManager final : public WebAuthnManagerBase, public AbortFollower {
|
||||||
void RunAbortAlgorithm() override;
|
void RunAbortAlgorithm() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// Cancels the current transaction (by sending a Cancel message to the
|
||||||
|
// parent) and rejects it by calling RejectTransaction().
|
||||||
|
void CancelTransaction(const nsresult& aError);
|
||||||
// Upon a visibility change, makes note of it in the current transaction.
|
// Upon a visibility change, makes note of it in the current transaction.
|
||||||
void HandleVisibilityChange() override;
|
void HandleVisibilityChange() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~WebAuthnManager();
|
virtual ~WebAuthnManager();
|
||||||
|
|
||||||
// Send a Cancel message to the parent, reject the promise with the given
|
// Rejects the current transaction and calls ClearTransaction().
|
||||||
// reason (an nsresult or JS::Handle<JS::Value>), and clear the transaction.
|
void RejectTransaction(const nsresult& aError);
|
||||||
template <typename T>
|
|
||||||
void CancelTransaction(const T& aReason) {
|
|
||||||
CancelParent();
|
|
||||||
RejectTransaction(aReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reject the promise with the given reason (an nsresult or JS::Value), and
|
|
||||||
// clear the transaction.
|
|
||||||
template <typename T>
|
|
||||||
void RejectTransaction(const T& aReason) {
|
|
||||||
if (!NS_WARN_IF(mTransaction.isNothing())) {
|
|
||||||
mTransaction.ref().mPromise->MaybeReject(aReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClearTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send a Cancel message to the parent.
|
|
||||||
void CancelParent();
|
|
||||||
|
|
||||||
// Clears all information we have about the current transaction.
|
// Clears all information we have about the current transaction.
|
||||||
void ClearTransaction();
|
void ClearTransaction();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
[createcredential-abort.https.html]
|
||||||
|
[navigator.credentials.create() after abort reason]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[navigator.credentials.create() before abort reason]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[navigator.credentials.create() after abort reason with Error]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[navigator.credentials.create() before abort reason with Error]
|
||||||
|
expected: FAIL
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
[getcredential-abort.https.html]
|
||||||
|
[navigator.credentials.get() after abort reason]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[navigator.credentials.get() before abort reason]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[navigator.credentials.get() after abort reason with Error]
|
||||||
|
expected: FAIL
|
||||||
|
|
||||||
|
[navigator.credentials.get() before abort reason with Error]
|
||||||
|
expected: FAIL
|
||||||
Loading…
Reference in a new issue