Skip to content

Commit

Permalink
Bug 1847323 [wpt PR 41346] - [FedCM] Split fedcm-network-requests.htt…
Browse files Browse the repository at this point in the history
…ps.html into multiple files, a=testonly

Automatic update from web-platform-tests
[FedCM] Split fedcm-network-requests.https.html into multiple files

The test is currently flaky timeout so we split into multiple files in
order to determine which one(s) timeout. Also, the auto reauthn test is
fixed to actually test reauthn.

Bug: 1404951
Change-Id: I40eff5d39652369ee0b98c438c553987c4efd5eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4753833
Commit-Queue: Nicolás Peña <npm@chromium.org>
Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1179752}

--

wpt-commits: 20bae55a19dd614fba324d2d352954ad8311eb48
wpt-pr: 41346
  • Loading branch information
npm1 authored and moz-wptsync-bot committed Aug 17, 2023
1 parent 2d5dba8 commit 3c7c661
Show file tree
Hide file tree
Showing 12 changed files with 342 additions and 210 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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 controller = new AbortController();
let test_options = request_options_with_mediation_required();
test_options.signal = controller.signal;
const cred = fedcm_get_and_select_first_account(t, test_options);
controller.abort();
return promise_rejects_dom(t, 'AbortError', cred);
}, "Test the abort signal");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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 controller = new AbortController();
let test_options = request_options_with_mediation_required();
test_options.signal = controller.signal;
const first_cred = fedcm_get_and_select_first_account(t, test_options);
controller.abort();
await promise_rejects_dom(t, 'AbortError', first_cred);

const second_cred = await fedcm_get_and_select_first_account(t, request_options_with_mediation_required());
assert_equals(second_cred.token, "token");
}, "Get after abort should work");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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>

<body>

<script type="module">
import {fedcm_test,
request_options_with_mediation_required,
fedcm_get_and_select_first_account} from './support/fedcm-helper.sub.js';

fedcm_test(async t => {
const cred = await fedcm_get_and_select_first_account(t, request_options_with_mediation_required());
assert_equals(cred.token, "token");
}, "Successfully obtaining token should resolve the promise.");

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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 => {
// Reset the client_metadata fetch count.
const clear_metadata_count_path = `support/fedcm/client_metadata_clear_count.py`;
await fetch(clear_metadata_count_path);

// FedCM flow causes the counter of client metadata to increase by 1.
const cred = await fedcm_get_and_select_first_account(t, request_options_with_mediation_required());
assert_equals(cred.token, "token");

await new Promise(resolve => {
// Fetch the client metadata from a popup window.
let popup_window = window.open('support/fedcm/client_metadata.py?skip_checks=1');
const popup_window_load_handler = (event) => {
popup_window.removeEventListener('load', popup_window_load_handler);
popup_window.close();
resolve();
};
popup_window.addEventListener('load', popup_window_load_handler);
});

const client_metadata_counter = await fetch(clear_metadata_count_path);
const client_metadata_counter_text = await client_metadata_counter.text();
// Check that the client metadata response is not cached. If the client metadata response was
// cached, when the user visits the IDP as a first party, the IDP would be able to determine the
// last RP the user visited regardless of whether the user granted consent via the FedCM prompt.
assert_equals(client_metadata_counter_text, "2");
}, 'Test client_metadata request is not cached');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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("manifest_redirect_accounts.json");
await select_manifest(t, test_options);

const cred = fedcm_get_and_select_first_account(t, test_options);
return promise_rejects_dom(t, 'NetworkError', cred);
}, 'Test that promise is rejected if accounts endpoint redirects');

fedcm_test(async t => {
let test_options = request_options_with_mediation_required("manifest_redirect_token.json");
await select_manifest(t, test_options);

const cred = fedcm_get_and_select_first_account(t, test_options);
return promise_rejects_dom(t, 'NetworkError', cred);
}, 'Test that token endpoint does not follow redirects');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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 test_options = request_options_with_mediation_required('manifest-not-in-list.json');
const cred = fedcm_get_and_select_first_account(t, test_options);
return promise_rejects_dom(t, 'NetworkError', cred);
}, 'Test that the promise is rejected if the manifest is not in the manifest list');
</script>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<title>Federated Credential Management API network request 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 test_options = request_options_with_mediation_required();
assert_true("nonce" in test_options.identity.providers[0]);
delete test_options.identity.providers[0].nonce;
const cred = await fedcm_get_and_select_first_account(t, test_options);
assert_equals(cred.token, "token");
}, "nonce is not required in FederatedIdentityProvider.");
</script>
Loading

0 comments on commit 3c7c661

Please sign in to comment.