diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/credential-management/fedcm-multi-idp | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/credential-management/fedcm-multi-idp')
12 files changed, 381 insertions, 0 deletions
diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/abort-multiple-gets-through-first-idp.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/abort-multiple-gets-through-first-idp.https.html new file mode 100644 index 0000000000..eb9f7da7b2 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/abort-multiple-gets-through-first-idp.https.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP abort first IDP test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script type="module"> + import { + set_fedcm_cookie, + set_alt_fedcm_cookie, + default_request_options, + default_alt_request_options + } from '../support/fedcm-helper.sub.js'; + + let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); + + promise_test(async t => { + let first_controller = new AbortController(); + let first_test_options = default_request_options(); + first_test_options.signal = first_controller.signal; + const first_cred = navigator.credentials.get(first_test_options); + + let second_controller = new AbortController(); + let second_test_options = default_alt_request_options(); + second_test_options.signal = second_controller.signal; + const second_cred = navigator.credentials.get(second_test_options); + + await cookies_promise; + first_controller.abort(); + return Promise.all([ + promise_rejects_dom(t, 'AbortError', first_cred), + promise_rejects_dom(t, 'AbortError', second_cred) + ]); + }, "Test abort signal for a multi IDP request by aborting the first IDP"); +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/abort-multiple-gets-through-second-idp.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/abort-multiple-gets-through-second-idp.https.html new file mode 100644 index 0000000000..7e7ec2ce3d --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/abort-multiple-gets-through-second-idp.https.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP abort second IDP test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script type="module"> + import { + set_fedcm_cookie, + set_alt_fedcm_cookie, + default_request_options, + default_alt_request_options + } from '../support/fedcm-helper.sub.js'; + + let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); + + promise_test(async t => { + let first_controller = new AbortController(); + let first_test_options = default_request_options(); + first_test_options.signal = first_controller.signal; + const first_cred = navigator.credentials.get(first_test_options); + + let second_controller = new AbortController(); + let second_test_options = default_alt_request_options(); + second_test_options.signal = second_controller.signal; + const second_cred = navigator.credentials.get(second_test_options); + + await cookies_promise; + second_controller.abort(); + return Promise.all([ + promise_rejects_dom(t, 'AbortError', first_cred), + promise_rejects_dom(t, 'AbortError', second_cred) + ]); + }, "Test abort signal for a multi IDP request by aborting the second IDP"); +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-after-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-after-onload.https.html new file mode 100644 index 0000000000..fa9ec7b52f --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-after-onload.https.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP get before and after onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, set_alt_fedcm_cookie, default_request_options, default_alt_request_options} from '../support/fedcm-helper.sub.js'; + +let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); +let has_window_loaded = false; +const window_loaded = new Promise(resolve => { + window.addEventListener('load', () => { + has_window_loaded = true; + resolve(); + }); +}); + +promise_test(async t => { + let first_cred_resolved = false; + assert_false(has_window_loaded); + // First navigator.credentials.get() is called prior to window.onload + const first_cred = navigator.credentials.get(default_request_options()).finally(() => { first_cred_resolved = true; }); + await Promise.all([cookies_promise, window_loaded]); + assert_true(has_window_loaded); + assert_false(first_cred_resolved); + // Second navigator.credentials.get() is called after window.onload but before first navigator.credentials.get() resolves + const second_cred = navigator.credentials.get(default_alt_request_options()); + const rejection = promise_rejects_dom(t, 'NotAllowedError', second_cred); + const first = await first_cred; + assert_equals(first.token, "token"); + return rejection; +}, "When there's a `get` call before onload, a `get` call which occurs after onload but before the first `get` call resolves, should be rejected."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-during-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-during-onload.https.html new file mode 100644 index 0000000000..93ee2075fe --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-during-onload.https.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP get before and during onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, set_alt_fedcm_cookie, default_request_options, default_alt_request_options} from '../support/fedcm-helper.sub.js'; + +let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); + +promise_test(async t => { + let has_window_loaded = false; + const window_loaded = new Promise(resolve => { + window.addEventListener('load', async () => { + const second_cred = navigator.credentials.get(default_alt_request_options()); + await promise_rejects_dom(t, 'NetworkError', second_cred); + has_window_loaded = true; + resolve(); + }); + }); + assert_false(has_window_loaded); + const first_cred = navigator.credentials.get(default_request_options()); + await Promise.all([cookies_promise, window_loaded]); + assert_true(has_window_loaded); + const first = await first_cred; + assert_equals(first.token, "token"); +}, "A `get` call before onload and a `get` call during onload should be combined."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-onload-and-during-dom-content-loaded.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-onload-and-during-dom-content-loaded.https.html new file mode 100644 index 0000000000..edc293daff --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-onload-and-during-dom-content-loaded.https.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP get before onload and during DOMContentLoaded test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, set_alt_fedcm_cookie, default_request_options, default_alt_request_options} from '../support/fedcm-helper.sub.js'; + +let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); + +promise_test(async t => { + let has_dom_content_loaded = false; + const dom_content_loaded = new Promise(resolve => { + document.addEventListener('DOMContentLoaded', async () => { + const second_cred = navigator.credentials.get(default_alt_request_options()); + await promise_rejects_dom(t, 'NetworkError', second_cred); + has_dom_content_loaded = true; + resolve(); + }); + }); + assert_false(has_dom_content_loaded); + const first_cred = navigator.credentials.get(default_request_options()); + await Promise.all([cookies_promise, dom_content_loaded]); + assert_true(has_dom_content_loaded); + const first = await first_cred; + assert_equals(first.token, "token"); +}, "A `get` call before onload and a `get` call during DOMContentLoaded event should combine despite being called from different tasks."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-abort.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-abort.https.html new file mode 100644 index 0000000000..b7b03e4a14 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-abort.https.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP get after abort test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script type="module"> + import { + set_fedcm_cookie, + set_alt_fedcm_cookie, + default_request_options, + default_alt_request_options + } from '../support/fedcm-helper.sub.js'; + + let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); + + promise_test(async t => { + let first_controller = new AbortController(); + let first_test_options = default_request_options(); + first_test_options.signal = first_controller.signal; + const first_cred = navigator.credentials.get(first_test_options); + + let second_controller = new AbortController(); + let second_test_options = default_alt_request_options(); + second_test_options.signal = second_controller.signal; + const second_cred = navigator.credentials.get(second_test_options); + + await cookies_promise; + second_controller.abort(); + await Promise.all([ + promise_rejects_dom(t, 'AbortError', first_cred), + promise_rejects_dom(t, 'AbortError', second_cred) + ]); + + const third_cred = navigator.credentials.get(default_request_options()); + const fourth_cred = navigator.credentials.get(default_alt_request_options()); + + // NetworkError is returned when another IDP is selected. + await promise_rejects_dom(t, 'NetworkError', fourth_cred); + const cred = await third_cred; + assert_equals(cred.token, "token"); + }, "Multiple gets after aborting a multi IDP request should work"); +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-onload.https.html new file mode 100644 index 0000000000..1a806a2049 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-onload.https.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP multiple gets after onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, set_alt_fedcm_cookie, default_request_options, default_alt_request_options} from '../support/fedcm-helper.sub.js'; + +let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); +const window_loaded = new Promise(resolve => { + window.addEventListener('load', () => { + resolve(); + }); +}); + +promise_test(async t => { + await Promise.all([cookies_promise, window_loaded]); + const first_cred = navigator.credentials.get(default_request_options()); + const second_cred = navigator.credentials.get(default_alt_request_options()); + // NetworkError is returned when another IDP is selected. + await promise_rejects_dom(t, 'NetworkError', second_cred); + const first = await first_cred; + assert_equals(first.token, "token"); +}, "No `get` calls before or during onload, multiple `get` calls after onload in the same task are allowed."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-before-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-before-onload.https.html new file mode 100644 index 0000000000..69a70ce47d --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-before-onload.https.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP multiple gets before onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, set_alt_fedcm_cookie, default_request_options, default_alt_request_options} from '../support/fedcm-helper.sub.js'; + +let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); +let has_window_loaded = false; +window.addEventListener('load', () => { + has_window_loaded = true; +}); + +// TODO(crbug.com/1374869): Add multi IDP test where second IDP is selected. +promise_test(async t => { + assert_false(has_window_loaded); + const first_cred = navigator.credentials.get(default_alt_request_options()); + const second_cred = navigator.credentials.get(default_request_options()); + await cookies_promise; + await promise_rejects_dom(t, 'NetworkError', second_cred); + const first = await first_cred; + assert_equals(first.token, "token"); +}, "Multiple get calls before window onload are allowed."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-during-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-during-onload.https.html new file mode 100644 index 0000000000..e98b63ff33 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-during-onload.https.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP multiple gets during onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, set_alt_fedcm_cookie, default_request_options, default_alt_request_options} from '../support/fedcm-helper.sub.js'; + +let cookies_promise = Promise.all([set_fedcm_cookie(), set_alt_fedcm_cookie()]); + +promise_test(async t => { + const window_loaded = new Promise(resolve => { + window.addEventListener('load', async () => { + const first_cred = navigator.credentials.get(default_request_options()); + const second_cred = navigator.credentials.get(default_alt_request_options()); + await cookies_promise; + await promise_rejects_dom(t, 'NetworkError', second_cred); + const first = await first_cred; + assert_equals(first.token, "token"); + resolve(); + }); + }); + await window_loaded; +}, "No `get` calls before onload, multiple `get` calls during onload are allowed."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-after-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-after-onload.https.html new file mode 100644 index 0000000000..a34ff84aab --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-after-onload.https.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP single get after onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, default_request_options} from '../support/fedcm-helper.sub.js'; + +const window_loaded = new Promise(resolve => { + window.addEventListener('load', () => { + resolve(); + }); +}); + +promise_test(async t => { + await set_fedcm_cookie(); + await window_loaded; + const cred = await navigator.credentials.get(default_request_options()); + assert_equals(cred.token, "token"); +}, "Single `get` call after onload is allowed."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-before-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-before-onload.https.html new file mode 100644 index 0000000000..91195fc5a7 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-before-onload.https.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP single get before onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {set_fedcm_cookie, default_request_options} from '../support/fedcm-helper.sub.js'; + +let has_window_loaded = false; +const window_loaded = new Promise(resolve => { + window.addEventListener('load', () => { + has_window_loaded = true; + resolve(); + }); +}); + +promise_test(async t => { + const first_cred = navigator.credentials.get(default_request_options()); + assert_false(has_window_loaded); + await set_fedcm_cookie(); + await window_loaded; + assert_true(has_window_loaded); + const first = await first_cred; + assert_equals(first.token, "token"); +}, "Single `get` call before onload is allowed."); + +</script> diff --git a/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-during-onload.https.html b/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-during-onload.https.html new file mode 100644 index 0000000000..17939d2d93 --- /dev/null +++ b/testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-during-onload.https.html @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<title>Federated Credential Management API multi IDP single get during onload test.</title> +<link rel="help" href="https://fedidcg.github.io/FedCM"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<body> + +<script type="module"> +import {default_request_options, set_fedcm_cookie} from '../support/fedcm-helper.sub.js'; + +promise_test(async t => { + const window_loaded = new Promise(resolve => { + window.addEventListener('load', async () => { + const first_cred = navigator.credentials.get(default_request_options()); + await set_fedcm_cookie(); + const first = await first_cred; + assert_equals(first.token, "token"); + resolve(); + }); + }); + await window_loaded; +}, "Single `get` call during onload is allowed."); + +</script> |