Skip to content

Commit

Permalink
Credential Management: use InvalidStateError for non-fully active docs
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=277125
rdar://132552299

Reviewed by NOBODY (OOPS!).

Switched from NotAllowedError to InvalidStateError for non-fully active documents.
Spec change:
w3c/webappsec-credential-management#245

* LayoutTests/imported/w3c/web-platform-tests/credential-management/non-fully-active.https.html:
* Source/WebCore/Modules/credentialmanagement/CredentialsContainer.cpp:
(WebCore::CredentialsContainer::preventSilentAccess const):
(WebCore::CredentialsContainer::performCommonChecks):
  • Loading branch information
marcoscaceres committed Jul 26, 2024
1 parent 9e839b2 commit ad3e3fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,28 +42,28 @@
// Try to get credentials while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
"InvalidStateError",
DOMExceptionCtor,
credentials.get({ signal }),
"Expected NotAllowedError for get() on non-fully-active document"
"Expected InvalidStateError for get() on non-fully-active document"
);

// Try to create credentials while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
"InvalidStateError",
DOMExceptionCtor,
credentials.create({ signal }),
"Expected NotAllowedError for create() on non-fully-active document"
"Expected InvalidStateError for create() on non-fully-active document"
);

// Try to prevent silent access while not fully active...
await promise_rejects_dom(
t,
"NotAllowedError",
"InvalidStateError",
DOMExceptionCtor,
credentials.preventSilentAccess(),
"Expected NotAllowedError for preventSilentAccess() on non-fully-active document"
"Expected InvalidStateError for preventSilentAccess() on non-fully-active document"
);
}, "non-fully active document behavior for CredentialsContainer");
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void CredentialsContainer::isCreate(CredentialCreationOptions&& options, Credent
void CredentialsContainer::preventSilentAccess(DOMPromiseDeferred<void>&& promise) const
{
if (document() && !document()->isFullyActive()) {
promise.reject(Exception { ExceptionCode::NotAllowedError, "The document is not fully active."_s });
promise.reject(Exception { ExceptionCode::InvalidStateError, "The document is not fully active."_s });
return;
}
promise.resolve();
Expand All @@ -144,12 +144,12 @@ bool CredentialsContainer::performCommonChecks(const Options& options, Credentia

RefPtr document = this->document();
if (!document->isFullyActive()) {
promise.reject(Exception { ExceptionCode::NotAllowedError, "The document is not fully active."_s });
promise.reject(Exception { ExceptionCode::InvalidStateError, "The document is not fully active."_s });
return false;
}

if (!document->page()) {
promise.reject(Exception { ExceptionCode::NotSupportedError, "No browsing context"_s });
promise.reject(Exception { ExceptionCode::InvalidStateError, "No browsing context"_s });
return false;
}

Expand Down

0 comments on commit ad3e3fc

Please sign in to comment.