зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1871056
[wpt PR 43750] - [FedCM] Add more WPT tests for error API, a=testonly
Automatic update from web-platform-tests [FedCM] Add more WPT tests for error API These tests make use of the newly repurposed webdriver command to click on buttons in the FedCM error dialog. Bug: 1496474 Change-Id: I8cdbd271c73d123dd47f62d943148b604412f08a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5021410 Reviewed-by: Christian Biesinger <cbiesinger@chromium.org> Commit-Queue: Zachary Tan <tanzachary@chromium.org> Cr-Commit-Position: refs/heads/main@{#1239840} -- wpt-commits: c84ca70108c0e0b26b731f16a4c2789040db66e4 wpt-pr: 43750
This commit is contained in:
Родитель
c1a5743b4e
Коммит
57795f2ab2
|
@ -11,17 +11,21 @@ import {request_options_with_mediation_required,
|
|||
fedcm_test,
|
||||
manifest_origin,
|
||||
select_manifest,
|
||||
fedcm_get_and_select_first_account} from './support/fedcm-helper.sub.js';
|
||||
fedcm_get_and_select_first_account,
|
||||
fedcm_error_dialog_dismiss,
|
||||
fedcm_error_dialog_click_button} from './support/fedcm-helper.sub.js';
|
||||
|
||||
const url_prefix = manifest_origin + '/credential-management/support/fedcm/';
|
||||
|
||||
fedcm_test(async t => {
|
||||
let test_options =
|
||||
request_options_with_mediation_required("manifest_id_assertion_endpoint_returns_error.json");
|
||||
request_options_with_mediation_required("manifest_id_assertion_endpoint_returns_error.json");
|
||||
await select_manifest(t, test_options);
|
||||
|
||||
try {
|
||||
const cred = await fedcm_get_and_select_first_account(t, test_options);
|
||||
fedcm_error_dialog_dismiss(t);
|
||||
await cred;
|
||||
assert_unreached("An IdentityCredentialError exception should be thrown.");
|
||||
} catch (e) {
|
||||
assert_true(e instanceof DOMException);
|
||||
|
@ -29,6 +33,42 @@ fedcm_test(async t => {
|
|||
assert_equals(e.code, "unauthorized_client");
|
||||
assert_equals(e.url, url_prefix + "error.html");
|
||||
}
|
||||
}, 'Test that the promise is rejected with proper error details');
|
||||
}, 'Test that the promise is rejected with proper error details when dialog is dismissed');
|
||||
|
||||
fedcm_test(async t => {
|
||||
let test_options =
|
||||
request_options_with_mediation_required("manifest_id_assertion_endpoint_returns_error.json");
|
||||
await select_manifest(t, test_options);
|
||||
|
||||
try {
|
||||
const cred = await fedcm_get_and_select_first_account(t, test_options);
|
||||
fedcm_error_dialog_click_button(t, "ErrorGotIt");
|
||||
await cred;
|
||||
assert_unreached("An IdentityCredentialError exception should be thrown.");
|
||||
} catch (e) {
|
||||
assert_true(e instanceof DOMException);
|
||||
assert_equals(e.name, "IdentityCredentialError");
|
||||
assert_equals(e.code, "unauthorized_client");
|
||||
assert_equals(e.url, url_prefix + "error.html");
|
||||
}
|
||||
}, 'Test that the promise is rejected with proper error details when got it is clicked');
|
||||
|
||||
fedcm_test(async t => {
|
||||
let test_options =
|
||||
request_options_with_mediation_required("manifest_id_assertion_endpoint_returns_error.json");
|
||||
await select_manifest(t, test_options);
|
||||
|
||||
try {
|
||||
const cred = await fedcm_get_and_select_first_account(t, test_options);
|
||||
fedcm_error_dialog_click_button(t, "ErrorMoreDetails");
|
||||
await cred;
|
||||
assert_unreached("An IdentityCredentialError exception should be thrown.");
|
||||
} catch (e) {
|
||||
assert_true(e instanceof DOMException);
|
||||
assert_equals(e.name, "IdentityCredentialError");
|
||||
assert_equals(e.code, "unauthorized_client");
|
||||
assert_equals(e.url, url_prefix + "error.html");
|
||||
}
|
||||
}, 'Test that the promise is rejected with proper error details when more details is clicked');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -213,6 +213,42 @@ export function fedcm_get_and_select_first_account(t, options) {
|
|||
return credentialPromise;
|
||||
}
|
||||
|
||||
export function fedcm_error_dialog_dismiss(t) {
|
||||
return new Promise(resolve => {
|
||||
async function helper() {
|
||||
// Try to select the account. If the UI is not up yet, we'll catch an exception
|
||||
// and try again in 100ms.
|
||||
try {
|
||||
let type = await fedcm_get_dialog_type_promise(t);
|
||||
assert_equals(type, "Error");
|
||||
await window.test_driver.cancel_fedcm_dialog();
|
||||
resolve();
|
||||
} catch (ex) {
|
||||
t.step_timeout(helper, 100);
|
||||
}
|
||||
}
|
||||
helper();
|
||||
});
|
||||
}
|
||||
|
||||
export function fedcm_error_dialog_click_button(t, button) {
|
||||
return new Promise(resolve => {
|
||||
async function helper() {
|
||||
// Try to select the account. If the UI is not up yet, we'll catch an exception
|
||||
// and try again in 100ms.
|
||||
try {
|
||||
let type = await fedcm_get_dialog_type_promise(t);
|
||||
assert_equals(type, "Error");
|
||||
await window.test_driver.click_fedcm_dialog_button(button);
|
||||
resolve();
|
||||
} catch (ex) {
|
||||
t.step_timeout(helper, 100);
|
||||
}
|
||||
}
|
||||
helper();
|
||||
});
|
||||
}
|
||||
|
||||
export function disconnect_options(accountHint, manifest_filename) {
|
||||
if (manifest_filename === undefined) {
|
||||
manifest_filename = "manifest.py";
|
||||
|
|
Загрузка…
Ссылка в новой задаче