summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/credential-management/fedcm-multi-idp
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/credential-management/fedcm-multi-idp')
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-after-onload.https.html37
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-and-during-onload.https.html32
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/get-before-onload-and-during-dom-content-loaded.https.html32
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-after-onload.https.html29
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-before-onload.https.html29
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/multiple-gets-during-onload.https.html29
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-after-onload.https.html25
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-before-onload.https.html30
-rw-r--r--testing/web-platform/tests/credential-management/fedcm-multi-idp/single-get-during-onload.https.html25
9 files changed, 268 insertions, 0 deletions
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-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>