content/browser/digital_credentials/README.md
This directory contains the browser-side implementation of the Digital Credentials API.
To test the Digital Credentials API (e.g., via Web Platform Tests), we need to simulate different user behaviors (e.g., successful selection, dismissal, aborting).
Since the real UI is platform-specific and requires user interaction, we use fake implementations for testing.
By default in test environments, we want the API calls
(navigator.credentials.get() and navigator.credentials.create()) to hang
(i.e., remain pending). This simulates the browser waiting indefinitely for the
user to interact with the UI.
This hanging behavior is crucial for testing:
AbortSignal can cancel a pending request.To achieve this:
DigitalIdentityProviderDesktop)
naturally hangs because it attempts to show a UI and waits for user
interaction (which never happens in automated tests).ShellContentBrowserClient overrides
CreateDigitalIdentityProvider to return ShellDigitalIdentityProvider,
which hangs by default (does not invoke the callback).HeadlessContentBrowserClient overrides
CreateDigitalIdentityProvider to return HeadlessDigitalIdentityProvider,
which also hangs by default.For tests that expect a successful token retrieval (e.g., wpt_internal
tests), we can configure the fake UI to auto-resolve with a fake token after
1ms.
This is enabled by passing the command-line flag:
--use-fake-ui-for-digital-identity
When this flag is present:
DigitalIdentityRequestImpl bypasses the embedder's provider.This flag is used in the digital-credentials-fake-ui virtual test suite
(defined in third_party/blink/web_tests/VirtualTestSuites) for running
success path tests.