Skip to content

Commit 0094c6e

Browse files
committed
Bug 1837056 [wpt PR 40399] - [FedCM] Add WPTs for loginHint, a=testonly
Automatic update from web-platform-tests [FedCM] Add WPTs for loginHint The base::Feature needs to be enabled in order to allow the WPTs to be run correctly. Note that the feature is still gated on the Blink RuntimeEnabledFeature. Bug: 1440192 Change-Id: I67a05889234451c126190c91030201dbfe5dbd60 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4595640 Reviewed-by: Christian Biesinger <cbiesingerchromium.org> Reviewed-by: Rakina Zata Amni <rakinachromium.org> Commit-Queue: Nicolás Peña <npmchromium.org> Cr-Commit-Position: refs/heads/main{#1154713} -- wpt-commits: 8969965f2a5f0e7ad096c87e336a06a17b2b89f4 wpt-pr: 40399 UltraBlame original commit: bac7683d8db624d8a53b1d9e3f19c15d8dcc2608
1 parent f5d90cc commit 0094c6e

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<title>Federated Credential Management API login hint tests.</title>
3+
<link rel="help" href="https://fedidcg.github.io/FedCM">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/service-workers/service-worker/resources/test-helpers.sub.js"></script>
7+
<body>
8+
9+
<script type="module">
10+
import {fedcm_test,
11+
request_options_with_login_hint,
12+
select_manifest} from './support/fedcm-helper.sub.js';
13+
14+
fedcm_test(async t => {
15+
let options = request_options_with_login_hint('manifest.py', 'nomatch');
16+
const cred = navigator.credentials.get(options);
17+
return promise_rejects_dom(t, "NetworkError", cred);
18+
}, "No login hint matches an account.");
19+
20+
fedcm_test(async t => {
21+
let options = request_options_with_login_hint('manifest.py', 'john_doe');
22+
const cred = await navigator.credentials.get(options);
23+
assert_equals(cred.token, 'token');
24+
}, "Login hint matches an account.");
25+
26+
fedcm_test(async t => {
27+
let options = request_options_with_login_hint('manifest_with_two_accounts.json', 'john_doe');
28+
await select_manifest(t, options);
29+
30+
const cred = await navigator.credentials.get(options);
31+
assert_equals(cred.token, 'account_id=john_doe');
32+
}, "Login hint matches an account from two accounts.");
33+
</script>

testing/web-platform/tests/credential-management/support/fedcm-helper.sub.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,10 @@ export function select_manifest(test, test_options) {
110110
const manifest_url = test_options.identity.providers[0].configURL;
111111
return select_manifest_impl(manifest_url);
112112
}
113+
114+
export function request_options_with_login_hint(manifest_filename, login_hint) {
115+
let options = request_options_with_mediation_required(manifest_filename);
116+
options.identity.providers[0].loginHint = login_hint;
117+
118+
return options;
119+
}

testing/web-platform/tests/credential-management/support/fedcm/accounts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def main(request, response):
2020
"name": "John Doe",
2121
"email": "[email protected]",
2222
"picture": "https://idp.example/profile/123",
23-
"approved_clients": ["123", "456", "789"]
23+
"approved_clients": ["123", "456", "789"],
24+
"login_hints": ["john_doe"]
2425
}]
2526
}
2627
"""

testing/web-platform/tests/credential-management/support/fedcm/two_accounts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def main(request, response):
2929
"name": "John Doe",
3030
"email": "[email protected]",
3131
"picture": "https://idp.example/profile/123",
32-
"approved_clients": ["123", "456", "789"]
32+
"approved_clients": ["123", "456", "789"],
33+
"login_hints": ["john_doe"]
3334
}
3435
]
3536
}

0 commit comments

Comments
 (0)