Skip to content

Commit d82b80f

Browse files
cbiesingerchromium-wpt-export-bot
authored andcommitted
[FedCM] Abort when an accounts fetch failed before OnClose
If we did get a signin status change and the accounts fetch failed, we should abort the flow in OnClose, to avoid getting stuck with a useless dialog. Bug: 421889736 Change-Id: I330db6257c17804214f0e24e3220680d954d43b3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6617245 Commit-Queue: Christian Biesinger <[email protected]> Reviewed-by: Nicolás Peña <[email protected]> Cr-Commit-Position: refs/heads/main@{#1470061}
1 parent 1f3beeb commit d82b80f

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>FedCM IDP log-in status API tests</title>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/resources/testdriver.js"></script>
7+
<script src="/resources/testdriver-vendor.js"></script>
8+
9+
<script type="module">
10+
import {request_options_with_mediation_required,
11+
fedcm_test,
12+
fedcm_get_dialog_type_promise,
13+
select_manifest,
14+
mark_signed_out} from '../support/fedcm-helper.sub.js';
15+
16+
fedcm_test(async t => {
17+
await mark_signed_out();
18+
19+
let test_options = request_options_with_mediation_required("manifest_no_accounts_login_delay.json");
20+
await select_manifest(t, test_options);
21+
22+
test_options.identity.mode = "active";
23+
let cred_promise = navigator.credentials.get(test_options);
24+
25+
// We should get the login popup window, which will automatically set
26+
// the login status and close itself.
27+
// The promise should get rejected because the accounts list is empty.
28+
29+
return promise_rejects_dom(t, 'NetworkError', cred_promise);
30+
}, 'Tests the IDP login dialog and subsequent account chooser.');
31+
</script>

fedcm/support/login_delay.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<script>
3+
async function doLogin() {
4+
navigator.login.setStatus("logged-in");
5+
// Delay the close call to allow the accounts fetch to complete beforehand.
6+
setTimeout(() => {
7+
IdentityProvider.close();
8+
}, 200);
9+
}
10+
window.onload = doLogin;
11+
</script>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"accounts_endpoint": "no_accounts.py",
3+
"client_metadata_endpoint": "client_metadata.py",
4+
"id_assertion_endpoint": "token_with_account_id.py",
5+
"login_url": "login_delay.html"
6+
}

lint.ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ SET TIMEOUT: encrypted-media/polyfill/clearkey-polyfill.js
173173
SET TIMEOUT: encrypted-media/scripts/playback-temporary-events.js
174174
SET TIMEOUT: fedcm/support/fedcm-iframe.html
175175
SET TIMEOUT: fedcm/support/fedcm/disconnect-iframe.html
176+
SET TIMEOUT: fedcm/support/login_delay.html
176177
SET TIMEOUT: fetch/fetch-later/resources/fetch-later-helper.js
177178
SET TIMEOUT: fetch/metadata/resources/helper.sub.js
178179
SET TIMEOUT: fetch/metadata/resources/message-opener.html

0 commit comments

Comments
 (0)