-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FedCM] Handle aborts for multi IDP requests
In a single IDP request, an abort will close the FedCM dialog. Currently, only the first IDP's abort will close the FedCM dialog. Until we reach a better solution for multi IDP aborts, we allow any IDP's abort to close the FedCM dialog. Bug: 1394913 Change-Id: I307ec1335a1359f6fb40598eab95a1855a6ecf08 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4160693 Reviewed-by: Christian Biesinger <[email protected]> Commit-Queue: Zachary Tan <[email protected]> Cr-Commit-Position: refs/heads/main@{#1092659}
- Loading branch information
1 parent
bb55ed8
commit 816912b
Showing
3 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
credential-management/fedcm-multi-idp/abort-multiple-gets-through-first-idp.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
35 changes: 35 additions & 0 deletions
35
credential-management/fedcm-multi-idp/abort-multiple-gets-through-second-idp.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
43 changes: 43 additions & 0 deletions
43
credential-management/fedcm-multi-idp/multiple-gets-after-abort.https.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |