summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html75
1 files changed, 75 insertions, 0 deletions
diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html
new file mode 100644
index 0000000000..587d57215b
--- /dev/null
+++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test that logins with non-matching formActionOrigin appear in autocomplete dropdown</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" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+Login Manager test: logins with non-matching formActionOrigin appear in autocomplete dropdown
+
+<script>
+const chromeScript = runChecksAfterCommonInit();
+</script>
+<p id="display"></p>
+<!-- we presumably can't hide the content for this test. -->
+<div id="content"></div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+/** Test for Login Manager: multiple login autocomplete. **/
+
+add_setup(async () => {
+ await addLoginsInParent(
+ [window.location.origin, "https://differentFormSubmitURL", null, "dfsu1", "dfsp1", "uname", "pword"]
+ );
+ listenForUnexpectedPopupShown();
+});
+
+add_task(async function test_form1_initial_empty() {
+ const form = createLoginForm();
+
+ await SimpleTest.promiseFocus(window);
+
+ // Make sure initial form is empty.
+ checkLoginForm(form.uname, "", form.pword, "");
+ const popupState = await getPopupState();
+ is(popupState.open, false, "Check popup is initially closed");
+});
+
+/* For this testcase, the only login that exists for this origin
+ * is one with a different formActionOrigin, so the login will appear
+ * in the autocomplete popup.
+ */
+add_task(async function test_form1_menu_shows_logins_for_different_formActionOrigin() {
+ const form = createLoginForm();
+
+ await SimpleTest.promiseFocus(window);
+
+ // Trigger autocomplete popup
+ form.uname.value = "";
+ form.pword.value = "";
+ form.uname.focus();
+
+ const autocompleteItems = await popupByArrowDown();
+
+ const popupState = await getPopupState();
+ is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
+
+ const expectedMenuItems = ["dfsu1"];
+ checkAutoCompleteResults(autocompleteItems, expectedMenuItems, window.location.host, "Check all menuitems are displayed correctly.");
+
+ synthesizeKey("KEY_ArrowDown"); // first item
+ checkLoginForm(form.uname, "", form.pword, ""); // value shouldn't update just by selecting
+
+ synthesizeKey("KEY_Enter");
+ await promiseFormsProcessedInSameProcess();
+ checkLoginForm(form.uname, "dfsu1", form.pword, "dfsp1");
+});
+</script>
+</pre>
+</body>
+</html>