chromium/third_party/blink/web_tests/http/tests/credentialmanagement/publickeycredential-basics.html

<!DOCTYPE html>
<title>Credential Manager: PublicKeyCredential basics.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script type="module">
import {AuthenticatorAttachment} from '/gen/third_party/blink/public/mojom/webauthn/authenticator.mojom.m.js';
import {TestAuthenticatorManager} from './resources/virtual-navigator-credentials.js';

if (document.location.host != "subdomain.example.test:8443") {
  document.location = "https://subdomain.example.test:8443/credentialmanagement/publickeycredential-basics.html";
  promise_test(_ => new Promise(_ => {}), "Stall tests on the wrong host.");
}

const manager = new TestAuthenticatorManager;

promise_test(async _ => {
  assert_false(await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable());
}, "isUserVerifyingPlatformAuthenticatorAvailable() is false if there are no platform authenticators.");

promise_test(async _ => {
  await manager.createAuthenticator({
    attachment: AuthenticatorAttachment.PLATFORM
  });
  assert_equals((await manager.authenticators()).length, 1);
  assert_true(await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable());
}, "isUserVerifyingPlatformAuthenticatorAvailable() is true if there are platform authenticators.");

promise_test(t => {
  return manager.clearAuthenticators();
}, "Clean up testing environment.");
</script>