Files
sousa-gecko/testing/web-platform/tests/webauthn/getcredential-ui-mode-immediate.https.html
T
Adem Derinel 244cc70c46 Bug 2013072 [wpt PR 57390] - WPTs for WebAuthn uiMode: 'immediate', a=testonly
Automatic update from web-platform-tests
WPTs for WebAuthn uiMode: 'immediate'

Include-Ci-Only-Tests: true
Bug: 426454491
Change-Id: I7443321f13f20de028fb5ed699d1d79357846ab7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7521744
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Commit-Queue: Adem Derinel <derinel@google.com>
Cr-Commit-Position: refs/heads/main@{#1582625}

--

wpt-commits: 7525d085093842262fb4ddc30500ee8f7ef48e7f
wpt-pr: 57390
2026-02-16 09:30:02 +00:00

153 lines
4.4 KiB
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>WebAuthn uiMode: 'immediate' Tests</title>
<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";
// Test uiMode: 'immediate' with mediation: 'optional' (Success case with Resident Key).
virtualAuthenticatorPromiseTest(async t => {
const credential = await createCredential({
options: {
publicKey: {
authenticatorSelection: {
residentKey: "required",
requireResidentKey: true,
}
}
}
});
await test_driver.bless("activate immediate mode");
const assertion = await navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(16),
rpId: window.location.hostname,
},
uiMode: "immediate",
});
assert_class_string(assertion, "PublicKeyCredential");
}, {
protocol: "ctap2",
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
transport: "internal",
}, "Immediate mediation (optional) with a resident credential");
// Test uiMode: 'immediate' with mediation: 'required' (Success case).
virtualAuthenticatorPromiseTest(async t => {
const credential = await createCredential({
options: {
publicKey: {
authenticatorSelection: {
residentKey: "required",
requireResidentKey: true,
}
}
}
});
await test_driver.bless("activate immediate mode");
const assertion = await navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(16),
rpId: window.location.hostname,
},
uiMode: "immediate",
mediation: "required"
});
assert_class_string(assertion, "PublicKeyCredential");
}, {
protocol: "ctap2",
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
transport: "internal",
}, "Immediate mediation (required) with a resident credential");
// Test uiMode: 'immediate' failure when allowCredentials is provided.
virtualAuthenticatorPromiseTest(async t => {
const credential = await createCredential();
await test_driver.bless("activate immediate mode");
const promise = navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(16),
rpId: window.location.hostname,
allowCredentials: [{
type: "public-key",
id: credential.rawId,
}],
},
uiMode: "immediate",
});
return promise_rejects_dom(t, "NotAllowedError", promise);
}, {
protocol: "ctap2",
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
transport: "internal",
}, "Immediate mediation fails if allowCredentials is not empty");
// Test uiMode: 'immediate' failure without user activation.
virtualAuthenticatorPromiseTest(async t => {
const credential = await createCredential();
const promise = navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(16),
rpId: window.location.hostname,
},
uiMode: "immediate",
});
return promise_rejects_dom(t, "NotAllowedError", promise);
}, {
protocol: "ctap2",
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
transport: "internal",
}, "Immediate mediation fails without user activation");
// Test uiMode: 'immediate' when no credentials are available.
virtualAuthenticatorPromiseTest(async t => {
await test_driver.bless("activate immediate mode");
const promise = navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(16),
rpId: window.location.hostname,
},
uiMode: "immediate",
mediation: "optional"
});
return promise_rejects_dom(t, "NotAllowedError", promise);
}, {
protocol: "ctap2",
hasResidentKey: true,
hasUserVerification: true,
transport: "internal",
}, "Immediate mediation (optional) with no credentials");
// Test uiMode: 'immediate' incompatibility with mediation: 'conditional'.
virtualAuthenticatorPromiseTest(async t => {
const promise = navigator.credentials.get({
publicKey: {
challenge: new Uint8Array(16),
rpId: window.location.hostname,
},
uiMode: "immediate",
mediation: "conditional"
});
return promise_rejects_dom(t, "NotSupportedError", promise);
}, {
protocol: "ctap2",
hasResidentKey: true,
hasUserVerification: true,
transport: "internal",
}, "Immediate mediation is incompatible with conditional mediation");
</script>