Files
sousa-gecko/testing/web-platform/tests/fedcm/fedcm-disconnect.sub.https.html
T
Jaimukund Bhan bdc7ace547 Bug 1980713 [wpt PR 54109] - [FedCM] Adding mark_signed_in to fedcm_test, a=testonly
Automatic update from web-platform-tests
[FedCM] Adding mark_signed_in to fedcm_test

Adding mark_signed_in to the beginning of fedcm_test ensures that user
is in a signed in state for each test. Tests calling mark_signed_out but
never sign back in cause flakiness in repeated test runs. This change
fixes that.

Bug: 41482163
Change-Id: Ib533bba63e73f59da32ce597f6a690873d0cf884
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6804547
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1495722}

--

wpt-commits: 3e6e1ad0173316a96004d5380e63633494f259f0
wpt-pr: 54109
2025-08-06 15:22:21 +00:00

96 lines
4.1 KiB
HTML

<!DOCTYPE html>
<title>Federated Credential Management API disconnect() tests.</title>
<meta name="timeout" content="long">
<link rel="help" href="https://fedidcg.github.io/FedCM">
<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>
<body>
<script type="module">
import {fedcm_test,
disconnect_options,
fedcm_get_and_select_first_account,
fedcm_select_account_promise,
request_options_with_mediation_required,
alt_manifest_origin,
alt_request_options_with_mediation_required,
alt_disconnect_options,
set_alt_fedcm_cookie} from './support/fedcm-helper.sub.js';
fedcm_test(async t => {
// Get at least one connected account that can be disconnected.
const cred = await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
// The IDP implementation will accept any account hint, so this is really testing that the user
// agent eventually stops sending the requests to the IDP.
// This test clears the connection just created above, but it also clears any previously existing
// connected accounts, which helps the logic of the other tests.
return new Promise(async resolve => {
while (true) {
try {
await IdentityCredential.disconnect(alt_disconnect_options("1234"));
} catch(e) {
resolve();
break;
}
}
});
}, "Repeatedly calling disconnect should eventually fail");
fedcm_test(async t => {
const disconnect = IdentityCredential.disconnect(
alt_disconnect_options("nonExistent"));
return promise_rejects_dom(t, 'NetworkError', disconnect);
}, 'Test that disconnect fails when there is no account to disconnect');
fedcm_test(async t => {
const cred = await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
return IdentityCredential.disconnect(alt_disconnect_options("1234"));
}, 'Test that disconnect succeeds when there is an account to disconnect');
fedcm_test(async t => {
const cred = await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
await IdentityCredential.disconnect(alt_disconnect_options("1234"));
const disconnect = IdentityCredential.disconnect(alt_disconnect_options("1234"));
return promise_rejects_dom(t, 'NetworkError', disconnect);
}, 'Test that disconnecting the same account twice results in failure.');
fedcm_test(async t => {
const cred = await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
// A connected account is guaranteed by the above, and IDP accepts any account hint, so this tests
// that the user agent allows the request to go through to the IDP.
return IdentityCredential.disconnect(alt_disconnect_options("noMatch"));
}, 'Disconnect passing an incorrect ID can still succeed');
fedcm_test(async t => {
await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
await fedcm_get_and_select_first_account(t,
request_options_with_mediation_required());
// Await the first disconnect since they cannot happen in parallel. Both
// should succeed.
await IdentityCredential.disconnect(disconnect_options("1"));
return IdentityCredential.disconnect(alt_disconnect_options("2"));
}, 'Disconnect is bound to each IDP');
fedcm_test(async t => {
// Get at least one connected account that can be disconnected.
await fedcm_get_and_select_first_account(t, alt_request_options_with_mediation_required());
// Pending get request.
const credentialPromise = navigator.credentials.get(alt_request_options_with_mediation_required());
// Disconnect the one connected account.
await IdentityCredential.disconnect(alt_disconnect_options("1234"));
// Select an account to resolve the pending get request.
fedcm_select_account_promise(t, 0);
return credentialPromise;
}, 'Test that disconnect succeeds when there is a pending get request and the get request succeeds after the disconnect');
</script>