diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html')
-rw-r--r-- | toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html | 79 |
1 files changed, 79 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..0365d5369c --- /dev/null +++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_basic_form_formActionOrigin.html @@ -0,0 +1,79 @@ +<!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> +<p id="display"></p> +<div id="content"></div> +<pre id="test"> +Login Manager test: logins with non-matching formActionOrigin appear in autocomplete dropdown + +<template id="form1-template"> + <form id="form1"> + <input type="text" name="uname"> + <input type="password" name="pword"> + </form> +</template> + +<script class="testbody" type="text/javascript"> + const formTemplate = document.getElementById("form1-template"); + + add_setup(async () => { + await setStoredLoginsDuringTest( + [window.location.origin, "https://differentFormSubmitURL", null, "dfsu1", "dfsp1", "uname", "pword"] + ); + listenForUnexpectedPopupShown(); + }); + + add_named_task("form initially empty", async () => { + const form = setContentForTask(formTemplate); + const autofillResult = await formAutofillResult(form.id); + is(autofillResult, "no_saved_logins", "form has not been filled due to no saved logins"); + is(form.uname.value, "", "username is empty"); + is(form.pword.value, "", "password is empty"); + 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_named_task("menu shows logins for different form action origin", async () => { + const form = setContentForTask(formTemplate); + const autofillResult = await formAutofillResult(form.id); + is(autofillResult, "no_saved_logins", "form has not been filled due to no saved logins"); + + // Trigger autocomplete popup + 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 + + // value shouldn't update just by selecting + is(form.uname.value, "", "username is empty"); + is(form.pword.value, "", "password is empty"); + + synthesizeKey("KEY_Enter"); + await untilAutocompletePopupClosed(); + is(form.uname.value, "dfsu1", "username is set"); + is(form.pword.value, "dfsp1", "password is set"); + }); +</script> +</pre> +</body> +</html> |