diff options
Diffstat (limited to 'testing/web-platform/tests/credential-management/fedcm-button-and-other-account')
4 files changed, 240 insertions, 0 deletions
diff --git a/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-basics.tentative.https.html b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-basics.tentative.https.html new file mode 100644 index 0000000000..a71e262135 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-basics.tentative.https.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<title>Federated Credential Management API Button Mode basic 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="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<script type="module"> +import {request_options_with_mediation_required, + fedcm_test, + select_manifest, + fedcm_get_and_select_first_account} from '../support/fedcm-helper.sub.js'; + +fedcm_test(async t => { + let test_options = request_options_with_mediation_required(); + test_options.identity.mode = "button"; + await select_manifest(t, test_options); + + let result = navigator.credentials.get(test_options); + return promise_rejects_dom(t, 'NetworkError', result); +}, "Test that the button mode without user activation will fail."); + +fedcm_test(async t => { + let test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + test_options.identity.mode = "button"; + + return test_driver.bless('initiate FedCM request', async function() { + let cred = await fedcm_get_and_select_first_account(t, test_options); + assert_equals(cred.token, "mode=button"); + }); +}, "Test that the button mode succeeds with user activation."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-priority.tentative.https.html b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-priority.tentative.https.html new file mode 100644 index 0000000000..b71e84db47 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-button-mode-priority.tentative.https.html @@ -0,0 +1,73 @@ +<!DOCTYPE html> +<title>Federated Credential Management API Button Mode priority 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="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<script type="module"> +import {request_options_with_mediation_required, + fedcm_test, + fedcm_get_and_select_first_account} from '../support/fedcm-helper.sub.js'; + +fedcm_test(async t => { + let widget_test_options = request_options_with_mediation_required(); + let button_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + button_test_options.identity.mode = "button"; + + return test_driver.bless('initiate FedCM request', async function() { + let first_cred = await fedcm_get_and_select_first_account(t, button_test_options); + assert_equals(first_cred.token, "mode=button"); + let second_cred = await fedcm_get_and_select_first_account(t, widget_test_options); + assert_equals(second_cred.token, "token"); + }); +}, "Test that the widget mode can succeed after the button mode."); + +fedcm_test(async t => { + let widget_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + let button_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + button_test_options.identity.mode = "button"; + + let first_cred = navigator.credentials.get(widget_test_options); + let rej = promise_rejects_dom(t, 'NetworkError', first_cred); + + return test_driver.bless('initiate FedCM request', async function() { + let second_cred = await fedcm_get_and_select_first_account(t, button_test_options); + assert_equals(second_cred.token, "mode=button"); + await rej; + }); + }, "Test that the button mode can replace widget mode."); + +fedcm_test(async t => { + let button_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + button_test_options.identity.mode = "button"; + + return test_driver.bless('initiate FedCM request', async function() { + let first_cred = fedcm_get_and_select_first_account(t, button_test_options); + let second_cred = navigator.credentials.get(button_test_options); + let rej = promise_rejects_dom(t, 'NotAllowedError', second_cred); + + let cred = await first_cred; + assert_equals(cred.token, "mode=button"); + await rej; + }); +}, "Test that the button mode cannot replace button mode."); + +fedcm_test(async t => { + let widget_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + let button_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json"); + button_test_options.identity.mode = "button"; + + return test_driver.bless('initiate FedCM request', async function() { + let first_cred = fedcm_get_and_select_first_account(t, button_test_options); + let second_cred = navigator.credentials.get(widget_test_options); + let rej = promise_rejects_dom(t, 'NotAllowedError', second_cred); + + let cred = await first_cred; + assert_equals(cred.token, "mode=button"); + await rej; + }); +}, "Test that the widget mode cannot replace button mode."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account-button-flow.tentative.https.html b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account-button-flow.tentative.https.html new file mode 100644 index 0000000000..996523af84 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account-button-flow.tentative.https.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<title>Federated Credential Management API Use Another Account API 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="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<script type="module"> +import {request_options_with_mediation_required, + fedcm_test, + fedcm_get_dialog_type_promise, + manifest_origin, + open_and_wait_for_popup, + select_manifest} from '../support/fedcm-helper.sub.js'; + +const url_path = '/credential-management/support/fedcm/' +const url_prefix = manifest_origin + url_path; + +async function set_accounts_cookie(value) { + await open_and_wait_for_popup(manifest_origin, url_path + 'set_accounts_cookie.py?' + value); +} + +fedcm_test(async t => { + await set_accounts_cookie("1"); + + let test_options = + request_options_with_mediation_required("manifest_with_variable_accounts.json"); + test_options.identity.mode = "button"; + await select_manifest(t, test_options); + + // Trigger FedCM and wait for the initial dialog. + let cred_promise = null; + await test_driver.bless('initiate FedCM request', async function() { + cred_promise = navigator.credentials.get(test_options); + }); + + let type = await fedcm_get_dialog_type_promise(t); + assert_equals(type, "AccountChooser"); + + // Tell the account endpoint to now return 2 accounts and click use other account. + await set_accounts_cookie("2"); + await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue"); + + // Wait for the account chooser to appear again. + type = await fedcm_get_dialog_type_promise(t); + assert_equals(type, "AccountChooser"); + + await window.test_driver.select_fedcm_account(1); + const cred = await cred_promise; + assert_equals(cred.token, "account_id=jane_doe"); +}, 'Test that the "Use Other Account" button works correctly.'); + + +fedcm_test(async t => { + await set_accounts_cookie("1"); + + let test_options = + request_options_with_mediation_required("manifest_with_variable_accounts.json"); + test_options.identity.mode = "button"; + await select_manifest(t, test_options); + + // Trigger FedCM and wait for the initial dialog. + let cred_promise = null; + await test_driver.bless('initiate FedCM request', async function() { + cred_promise = navigator.credentials.get(test_options); + }); + + let type = await fedcm_get_dialog_type_promise(t); + assert_equals(type, "AccountChooser"); + + // Click use other account but without changing the account returned. + await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue"); + + // Wait for the account chooser to appear again. + type = await fedcm_get_dialog_type_promise(t); + assert_equals(type, "AccountChooser"); + + await window.test_driver.select_fedcm_account(0); + const cred = await cred_promise; + assert_equals(cred.token, "account_id=1234"); +}, 'Test that the "Use Other Account" button works correctly when accounts do not change.'); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account.tentative.https.html b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account.tentative.https.html new file mode 100644 index 0000000000..2022bbc0f7 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-button-and-other-account/fedcm-use-other-account.tentative.https.html @@ -0,0 +1,49 @@ +<!DOCTYPE html> +<title>Federated Credential Management API Use Another Account API 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="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> + +<script type="module"> +import {request_options_with_mediation_required, + fedcm_test, + fedcm_get_dialog_type_promise, + manifest_origin, + open_and_wait_for_popup, + select_manifest} from '../support/fedcm-helper.sub.js'; + +const url_path = '/credential-management/support/fedcm/' +const url_prefix = manifest_origin + url_path; + +async function set_accounts_cookie(value) { + await open_and_wait_for_popup(manifest_origin, url_path + 'set_accounts_cookie.py?' + value); +} + +fedcm_test(async t => { + await set_accounts_cookie("1"); + + let test_options = + request_options_with_mediation_required("manifest_with_variable_accounts.json"); + await select_manifest(t, test_options); + + // Trigger FedCM and wait for the initial dialog. + const cred_promise = navigator.credentials.get(test_options); + let type = await fedcm_get_dialog_type_promise(t); + assert_equals(type, "AccountChooser"); + + // Tell the account endpoint to now return 2 accounts and click use other account. + await set_accounts_cookie("2"); + await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue"); + + // Wait for the account chooser to appear again. + type = await fedcm_get_dialog_type_promise(t); + assert_equals(type, "AccountChooser"); + + await window.test_driver.select_fedcm_account(1); + const cred = await cred_promise; + assert_equals(cred.token, "account_id=jane_doe"); +}, 'Test that the "Use Other Account" button works correctly.'); + +</script> |