Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!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>