Skip to content

Commit

Permalink
[FedCM] Split button flow web tests into multiple files
Browse files Browse the repository at this point in the history
The basic tests file would grow with more tests coming so it makes sense
to split some into a new file. In addition, this helps with debugging
new flaky tests.

Bug: 328129675, 41489720
Change-Id: Ie3cde046b3e13febdb3d57bf8cce7567ddb530dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5352771
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Auto-Submit: Yi Gu <yigu@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1270323}
  • Loading branch information
yi-gu authored and chromium-wpt-export-bot committed Mar 8, 2024
1 parent 85e057d commit 9208837
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<title>Federated Credential Management API auto selected flag tests.</title>
<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>
Expand All @@ -9,28 +9,22 @@
<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_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";

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";
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 cred = await fedcm_get_and_select_first_account(t, test_options);
assert_equals(cred.token, "mode=button");
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 button mode requires user activation.");
}, "Test that the widget mode can succeed after the button mode.");

fedcm_test(async t => {
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";
Expand All @@ -45,19 +39,6 @@
});
}, "Test that the button mode can replace widget mode.");

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 button_test_options = request_options_with_mediation_required("manifest_with_rp_mode.json");
button_test_options.identity.mode = "button";
Expand Down

0 comments on commit 9208837

Please sign in to comment.