diff --git a/testing/web-platform/tests/credential-management/fedcm-loginhint.https.html b/testing/web-platform/tests/credential-management/fedcm-loginhint.https.html new file mode 100644 index 0000000000000..0c70ce1713074 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-loginhint.https.html @@ -0,0 +1,322 @@ +< +! +DOCTYPE +html +> +< +title +> +Federated +Credential +Management +API +login +hint +tests +. +< +/ +title +> +< +link +rel += +" +help +" +href += +" +https +: +/ +/ +fedidcg +. +github +. +io +/ +FedCM +" +> +< +script +src += +" +/ +resources +/ +testharness +. +js +" +> +< +/ +script +> +< +script +src += +" +/ +resources +/ +testharnessreport +. +js +" +> +< +/ +script +> +< +script +src += +" +/ +service +- +workers +/ +service +- +worker +/ +resources +/ +test +- +helpers +. +sub +. +js +" +> +< +/ +script +> +< +body +> +< +script +type += +" +module +" +> +import +{ +fedcm_test +request_options_with_login_hint +select_manifest +} +from +' +. +/ +support +/ +fedcm +- +helper +. +sub +. +js +' +; +fedcm_test +( +async +t += +> +{ +let +options += +request_options_with_login_hint +( +' +manifest +. +py +' +' +nomatch +' +) +; +const +cred += +navigator +. +credentials +. +get +( +options +) +; +return +promise_rejects_dom +( +t +" +NetworkError +" +cred +) +; +} +" +No +login +hint +matches +an +account +. +" +) +; +fedcm_test +( +async +t += +> +{ +let +options += +request_options_with_login_hint +( +' +manifest +. +py +' +' +john_doe +' +) +; +const +cred += +await +navigator +. +credentials +. +get +( +options +) +; +assert_equals +( +cred +. +token +' +token +' +) +; +} +" +Login +hint +matches +an +account +. +" +) +; +fedcm_test +( +async +t += +> +{ +let +options += +request_options_with_login_hint +( +' +manifest_with_two_accounts +. +json +' +' +john_doe +' +) +; +await +select_manifest +( +t +options +) +; +const +cred += +await +navigator +. +credentials +. +get +( +options +) +; +assert_equals +( +cred +. +token +' +account_id += +john_doe +' +) +; +} +" +Login +hint +matches +an +account +from +two +accounts +. +" +) +; +< +/ +script +> diff --git a/testing/web-platform/tests/credential-management/support/fedcm-helper.sub.js b/testing/web-platform/tests/credential-management/support/fedcm-helper.sub.js index 13d3234517541..92ae1956fa7ce 100644 --- a/testing/web-platform/tests/credential-management/support/fedcm-helper.sub.js +++ b/testing/web-platform/tests/credential-management/support/fedcm-helper.sub.js @@ -707,3 +707,36 @@ manifest_url ) ; } +export +function +request_options_with_login_hint +( +manifest_filename +login_hint +) +{ +let +options += +request_options_with_mediation_required +( +manifest_filename +) +; +options +. +identity +. +providers +[ +0 +] +. +loginHint += +login_hint +; +return +options +; +} diff --git a/testing/web-platform/tests/credential-management/support/fedcm/accounts.py b/testing/web-platform/tests/credential-management/support/fedcm/accounts.py index 7a8dfea581d5b..c3fe4203746b7 100644 --- a/testing/web-platform/tests/credential-management/support/fedcm/accounts.py +++ b/testing/web-platform/tests/credential-management/support/fedcm/accounts.py @@ -266,6 +266,16 @@ 789 " ] + +" +login_hints +" +: +[ +" +john_doe +" +] } ] diff --git a/testing/web-platform/tests/credential-management/support/fedcm/two_accounts.py b/testing/web-platform/tests/credential-management/support/fedcm/two_accounts.py index 415cfaf693d49..42b5a802a0db6 100644 --- a/testing/web-platform/tests/credential-management/support/fedcm/two_accounts.py +++ b/testing/web-platform/tests/credential-management/support/fedcm/two_accounts.py @@ -338,6 +338,16 @@ 789 " ] + +" +login_hints +" +: +[ +" +john_doe +" +] }