mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-23 04:43:07 +09:00
147 lines
4.5 KiB
HTML
147 lines
4.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test autocomplete due to multiple matching logins</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
|
<script type="text/javascript" src="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: autocomplete due to multiple matching logins
|
|
|
|
<script>
|
|
runChecksAfterCommonInit(false);
|
|
|
|
SpecialPowers.loadChromeScript(function addLogins() {
|
|
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
// Create some logins just for this form, since we'll be deleting them.
|
|
var nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
|
|
Ci.nsILoginInfo, "init");
|
|
|
|
var login0 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
|
|
"name", "pass", "uname", "pword");
|
|
|
|
var login1 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
|
|
"Name", "Pass", "uname", "pword");
|
|
|
|
var login2 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
|
|
"USER", "PASS", "uname", "pword");
|
|
|
|
try {
|
|
Services.logins.addLogin(login0);
|
|
Services.logins.addLogin(login1);
|
|
Services.logins.addLogin(login2);
|
|
} catch (e) {
|
|
assert.ok(false, "addLogin threw: " + e);
|
|
}
|
|
});
|
|
</script>
|
|
<p id="display"></p>
|
|
|
|
<!-- we presumably can't hide the content for this test. -->
|
|
<div id="content">
|
|
|
|
<!-- form1 tests multiple matching logins -->
|
|
<form id="form1" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
|
|
<input type="text" name="uname">
|
|
<input type="password" name="pword">
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
/** Test for Login Manager: autocomplete due to multiple matching logins **/
|
|
|
|
var uname = $_(1, "uname");
|
|
var pword = $_(1, "pword");
|
|
|
|
// Restore the form to the default state.
|
|
function restoreForm() {
|
|
uname.value = "";
|
|
pword.value = "";
|
|
uname.focus();
|
|
}
|
|
|
|
// Check for expected username/password in form.
|
|
function checkACForm(expectedUsername, expectedPassword) {
|
|
var formID = uname.parentNode.id;
|
|
is(uname.value, expectedUsername, "Checking " + formID + " username");
|
|
is(pword.value, expectedPassword, "Checking " + formID + " password");
|
|
}
|
|
|
|
add_task(function* test_empty_first_entry() {
|
|
/* test 1 */
|
|
// Make sure initial form is empty.
|
|
checkACForm("", "");
|
|
// Trigger autocomplete popup
|
|
restoreForm();
|
|
let popupState = yield getPopupState();
|
|
is(popupState.open, false, "Check popup is initially closed");
|
|
let shownPromise = promiseACShown();
|
|
doKey("down");
|
|
let results = yield shownPromise;
|
|
popupState = yield getPopupState();
|
|
is(popupState.selectedIndex, -1, "Check no entries are selected");
|
|
checkArrayValues(results, ["name", "Name", "USER"], "initial");
|
|
|
|
// Check first entry
|
|
let index0Promise = notifySelectedIndex(0);
|
|
doKey("down");
|
|
yield index0Promise;
|
|
checkACForm("", ""); // value shouldn't update
|
|
doKey("return"); // not "enter"!
|
|
yield promiseFormsProcessed();
|
|
checkACForm("name", "pass");
|
|
});
|
|
|
|
add_task(function* test_empty_second_entry() {
|
|
restoreForm();
|
|
let shownPromise = promiseACShown();
|
|
doKey("down"); // open
|
|
yield shownPromise;
|
|
doKey("down"); // first
|
|
doKey("down"); // second
|
|
doKey("return"); // not "enter"!
|
|
yield promiseFormsProcessed();
|
|
checkACForm("Name", "Pass");
|
|
});
|
|
|
|
add_task(function* test_empty_third_entry() {
|
|
restoreForm();
|
|
let shownPromise = promiseACShown();
|
|
doKey("down"); // open
|
|
yield shownPromise;
|
|
doKey("down"); // first
|
|
doKey("down"); // second
|
|
doKey("down"); // third
|
|
doKey("return");
|
|
yield promiseFormsProcessed();
|
|
checkACForm("USER", "PASS");
|
|
});
|
|
|
|
add_task(function* test_preserve_matching_username_case() {
|
|
restoreForm();
|
|
uname.value = "user";
|
|
let shownPromise = promiseACShown();
|
|
doKey("down"); // open
|
|
yield shownPromise;
|
|
|
|
// Check that we don't clobber user-entered text when tabbing away
|
|
// (even with no autocomplete entry selected)
|
|
doKey("tab");
|
|
yield promiseFormsProcessed();
|
|
checkACForm("user", "PASS");
|
|
});
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|