зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1883545 [wpt PR 44923] - [FedCM] Add a webdriver command for the "Use Other Account" button, a=testonly
Automatic update from web-platform-tests [FedCM] Add a webdriver command for the "Use Other Account" button Bug: 327458808 Change-Id: Ia9c575f61772588efbaa72943115de250c225433 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5341752 Reviewed-by: Robert Flack <flackr@chromium.org> Commit-Queue: Christian Biesinger <cbiesinger@chromium.org> Cr-Commit-Position: refs/heads/main@{#1268650} -- wpt-commits: 43f7c2c9b3353d526ceb65f263dcfa2be47e5d64 wpt-pr: 44923
This commit is contained in:
Родитель
6c09c49838
Коммит
7ce61e321d
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Federated Credential Management API Use Another Account API 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_dialog_type_promise,
|
||||
manifest_origin,
|
||||
open_and_wait_for_popup,
|
||||
select_manifest} from '../support/fedcm-helper.sub.js';
|
||||
|
||||
const url_path = '/credential-management/support/fedcm/'
|
||||
const url_prefix = manifest_origin + url_path;
|
||||
|
||||
async function set_accounts_cookie(value) {
|
||||
await open_and_wait_for_popup(manifest_origin, url_path + 'set_accounts_cookie.py?' + value);
|
||||
}
|
||||
|
||||
fedcm_test(async t => {
|
||||
await set_accounts_cookie("1");
|
||||
|
||||
let test_options =
|
||||
request_options_with_mediation_required("manifest_with_variable_accounts.json");
|
||||
test_options.identity.mode = "button";
|
||||
await select_manifest(t, test_options);
|
||||
|
||||
// Trigger FedCM and wait for the initial dialog.
|
||||
let cred_promise = null;
|
||||
await test_driver.bless('initiate FedCM request', async function() {
|
||||
cred_promise = navigator.credentials.get(test_options);
|
||||
});
|
||||
|
||||
let type = await fedcm_get_dialog_type_promise(t);
|
||||
assert_equals(type, "AccountChooser");
|
||||
|
||||
// Tell the account endpoint to now return 2 accounts and click use other account.
|
||||
await set_accounts_cookie("2");
|
||||
await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue");
|
||||
|
||||
// Wait for the account chooser to appear again.
|
||||
type = await fedcm_get_dialog_type_promise(t);
|
||||
assert_equals(type, "AccountChooser");
|
||||
|
||||
await window.test_driver.select_fedcm_account(1);
|
||||
const cred = await cred_promise;
|
||||
assert_equals(cred.token, "account_id=jane_doe");
|
||||
}, 'Test that the "Use Other Account" button works correctly.');
|
||||
|
||||
</script>
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Federated Credential Management API Use Another Account API 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_dialog_type_promise,
|
||||
manifest_origin,
|
||||
open_and_wait_for_popup,
|
||||
select_manifest} from '../support/fedcm-helper.sub.js';
|
||||
|
||||
const url_path = '/credential-management/support/fedcm/'
|
||||
const url_prefix = manifest_origin + url_path;
|
||||
|
||||
async function set_accounts_cookie(value) {
|
||||
await open_and_wait_for_popup(manifest_origin, url_path + 'set_accounts_cookie.py?' + value);
|
||||
}
|
||||
|
||||
fedcm_test(async t => {
|
||||
await set_accounts_cookie("1");
|
||||
|
||||
let test_options =
|
||||
request_options_with_mediation_required("manifest_with_variable_accounts.json");
|
||||
await select_manifest(t, test_options);
|
||||
|
||||
// Trigger FedCM and wait for the initial dialog.
|
||||
const cred_promise = navigator.credentials.get(test_options);
|
||||
let type = await fedcm_get_dialog_type_promise(t);
|
||||
assert_equals(type, "AccountChooser");
|
||||
|
||||
// Tell the account endpoint to now return 2 accounts and click use other account.
|
||||
await set_accounts_cookie("2");
|
||||
await window.test_driver.click_fedcm_dialog_button("ConfirmIdpLoginContinue");
|
||||
|
||||
// Wait for the account chooser to appear again.
|
||||
type = await fedcm_get_dialog_type_promise(t);
|
||||
assert_equals(type, "AccountChooser");
|
||||
|
||||
await window.test_driver.select_fedcm_account(1);
|
||||
const cred = await cred_promise;
|
||||
assert_equals(cred.token, "account_id=jane_doe");
|
||||
}, 'Test that the "Use Other Account" button works correctly.');
|
||||
|
||||
</script>
|
|
@ -2,5 +2,13 @@
|
|||
"accounts_endpoint": "variable_accounts.py",
|
||||
"client_metadata_endpoint": "client_metadata.py",
|
||||
"id_assertion_endpoint": "token_with_account_id.py",
|
||||
"login_url": "login.html"
|
||||
"login_url": "login.html",
|
||||
"modes": {
|
||||
"button": {
|
||||
"supports_use_other_account": true
|
||||
},
|
||||
"widget": {
|
||||
"supports_use_other_account": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
def main(request, response):
|
||||
query_string = request.url_parts[3]
|
||||
# We mark the cookie as HttpOnly so that this request
|
||||
# can be made before login.html, which would overwrite
|
||||
# the value to 1.
|
||||
header_value = "accounts={}; SameSite=None; Secure; HttpOnly".format(query_string)
|
||||
response.headers.set(b"Set-Cookie", header_value.encode("utf-8"))
|
||||
response.headers.set(b"Content-Type", b"text/html")
|
||||
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<script>
|
||||
// The important part of this page are the headers.
|
||||
|
||||
// If this page was opened as a popup, notify the opener.
|
||||
if (window.opener) {
|
||||
window.opener.postMessage("done_loading", "*");
|
||||
}
|
||||
</script>
|
||||
Sent header value: {}".format(header_value)
|
||||
"""
|
|
@ -1,25 +1,14 @@
|
|||
import importlib
|
||||
error_checker = importlib.import_module("credential-management.support.fedcm.request-params-check")
|
||||
|
||||
def main(request, response):
|
||||
request_error = error_checker.accountsCheck(request)
|
||||
if (request_error):
|
||||
return request_error
|
||||
|
||||
response.headers.set(b"Content-Type", b"application/json")
|
||||
|
||||
if request.cookies.get(b"accounts") != b"1":
|
||||
return """
|
||||
{
|
||||
"accounts": [
|
||||
]
|
||||
}
|
||||
result_json = """
|
||||
{{
|
||||
"accounts": [{}]
|
||||
}}
|
||||
"""
|
||||
|
||||
|
||||
return """
|
||||
one_account = """
|
||||
{
|
||||
"accounts": [{
|
||||
"id": "1234",
|
||||
"given_name": "John",
|
||||
"name": "John Doe",
|
||||
|
@ -28,6 +17,33 @@ def main(request, response):
|
|||
"approved_clients": ["123", "456", "789"],
|
||||
"login_hints": ["john_doe"],
|
||||
"hosted_domains": ["idp.example", "example"]
|
||||
}]
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
two_accounts = one_account + """
|
||||
, {
|
||||
"id": "jane_doe",
|
||||
"given_name": "Jane",
|
||||
"name": "Jane Doe",
|
||||
"email": "jane_doe@idp.example",
|
||||
"picture": "https://idp.example/profile/5678",
|
||||
"approved_clients": ["123", "abc"]
|
||||
}
|
||||
"""
|
||||
|
||||
def main(request, response):
|
||||
request_error = error_checker.accountsCheck(request)
|
||||
if (request_error):
|
||||
return request_error
|
||||
|
||||
response.headers.set(b"Content-Type", b"application/json")
|
||||
|
||||
if request.cookies.get(b"accounts") == b"1":
|
||||
return result_json.format(one_account)
|
||||
if request.cookies.get(b"accounts") == b"2":
|
||||
return result_json.format(two_accounts)
|
||||
|
||||
return result_json.format("")
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче