diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_related_realms.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_related_realms.html')
-rw-r--r-- | toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_related_realms.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_related_realms.html b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_related_realms.html new file mode 100644 index 0000000000..988cd05954 --- /dev/null +++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_related_realms.html @@ -0,0 +1,106 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test login autocomplete with related realms</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <script type="text/javascript" src="../../../satchel/test/satchel_common.js"></script> + <script type="text/javascript" src="pwmgr_common.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> +</head> +<body> +Login Manager test: related realms autocomplete +<p id="display"></p> +<div id="content"></div> +<pre id="test"> +<script class="testbody" type="text/javascript"> +/** Test for Login Manager: related realms autocomplete. **/ + +function sendFakeAutocompleteEvent(element) { + var acEvent = document.createEvent("HTMLEvents"); + acEvent.initEvent("DOMAutoComplete", true, false); + element.dispatchEvent(acEvent); +} + +async function promiseACPopupClosed() { + return SimpleTest.promiseWaitForCondition(async () => { + const popupState = await getPopupState(); + return !popupState.open; + }, "Wait for AC popup to be closed"); +} + +add_setup(async () => { + await setStoredLoginsAsync( + // Simple related domain relationship where example.com and other-example.com are in the related domains list + ["https://other-example.com", "https://other-example.com", null, "relatedUser1", "relatedPass1", "uname", "pword"], + + // Example.com and example.co.uk are related, so sub.example.co.uk should appear on example.com's autocomplete dropdown + // The intent is to cover the ebay.com/ebay.co.uk and all other country TLD cases + // where the sign in page is actually signin.ebay.com/signin.ebay.co.uk but credentials could have manually been entered + // for ebay.com/ebay.co.uk or automatically stored as signin.ebay.com/sigin.ebay.co.uk + ["https://sub.example.co.uk", "https://sub.example.co.uk", null, "subUser1", "subPass1", "uname", "pword"], + ); + listenForUnexpectedPopupShown(); +}); + +add_task(async function test_form1_initial_empty() { + const form = createLoginForm(); + await promiseFormsProcessedInSameProcess(); + + // Make sure initial form is empty. + checkLoginForm(form.uname, "", form.pword, ""); + const popupState = await getPopupState(); + is(popupState.open, false, "Check popup is initially closed"); +}); + +add_task(async function test_form_related_domain_menuitems() { + const form = createLoginForm(); + await promiseFormsProcessedInSameProcess(); + + form.uname.focus(); + + const autocompleteItems = await popupByArrowDown(); + const popupState = await getPopupState(); + + is(popupState.selectedIndex, -1, "Check no entires are selected upon opening"); + + const expectedMenuItems = ["relatedUser1", "subUser1"]; + checkAutoCompleteResults(autocompleteItems, expectedMenuItems, window.location.host, "Check all menuitems are displayed correctly"); + + const acEvents = await getTelemetryEvents({ process: "parent", filterProps: TelemetryFilterPropsAC, clear: true }); + is(acEvents.length, 1, "One autocomplete event"); + checkACTelemetryEvent(acEvents[0], form.uname, { + "hadPrevious": "0", + "login": expectedMenuItems.length + "", + "loginsFooter": "1" + }); + checkLoginForm(form.uname, "", form.pword, ""); // value shouldn't update just by opening + + synthesizeKey("KEY_ArrowDown"); // first item + checkLoginForm(form.uname, "", form.pword, ""); // value shouldn't update just by selecting + + synthesizeKey("KEY_Enter"); + await promiseFormsProcessedInSameProcess(); + is(form.pword.value, "relatedPass1", "password should match the login that was selected"); + checkLoginForm(form.uname, "relatedUser1", form.pword, "relatedPass1"); + + form.uname.value = ""; + form.pword.value = ""; + form.uname.focus(); + + await popupByArrowDown(); + + synthesizeKey("KEY_ArrowDown"); // first item + synthesizeKey("KEY_ArrowDown"); // second item + checkLoginForm(form.uname, "", form.pword, ""); // value shouldn't update just by selecting + + synthesizeKey("KEY_Enter"); + await promiseFormsProcessedInSameProcess(); + is(form.pword.value, "subPass1", "password should match the login that was selected"); + checkLoginForm(form.uname, "subUser1", form.pword, "subPass1"); +}); +</script> +</pre> +</body> +</html> |