summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html')
-rw-r--r--toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html291
1 files changed, 0 insertions, 291 deletions
diff --git a/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html b/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
deleted file mode 100644
index 443c8a5e9..000000000
--- a/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html
+++ /dev/null
@@ -1,291 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Test basic login autocomplete</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: multiple login autocomplete
-
-<script>
-var chromeScript = runChecksAfterCommonInit();
-
-var setupScript = runInParent(function setup() {
- 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");
- assert.ok(nsLoginInfo != null, "nsLoginInfo constructor");
-
- // login0 has no username, so should be filtered out from the autocomplete list.
- var login0 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
- "", "user0pass", "", "pword");
-
- var login1 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
- "tempuser1", "temppass1", "uname", "pword");
-
- var login2 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
- "testuser2", "testpass2", "uname", "pword");
-
- var login3 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
- "testuser3", "testpass3", "uname", "pword");
-
- var login4 = new nsLoginInfo("http://mochi.test:8888", "http://autocomplete:8888", null,
- "zzzuser4", "zzzpass4", "uname", "pword");
-
-
- // try/catch in case someone runs the tests manually, twice.
- try {
- Services.logins.addLogin(login0);
- Services.logins.addLogin(login1);
- Services.logins.addLogin(login2);
- Services.logins.addLogin(login3);
- Services.logins.addLogin(login4);
- } catch (e) {
- assert.ok(false, "addLogin threw: " + e);
- }
-
- addMessageListener("addLogin", loginVariableName => {
- let login = eval(loginVariableName);
- assert.ok(!!login, "Login to add is defined: " + loginVariableName);
- Services.logins.addLogin(login);
- });
- addMessageListener("removeLogin", loginVariableName => {
- let login = eval(loginVariableName);
- assert.ok(!!login, "Login to delete is defined: " + loginVariableName);
- Services.logins.removeLogin(login);
- });
-});
-</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>
-
- <form id="form2" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
- <input type="text" name="uname">
- <input type="password" name="pword" readonly="true">
- <button type="submit">Submit</button>
- </form>
-
- <form id="form3" action="http://autocomplete:8888/formtest.js" onsubmit="return false;">
- <input type="text" name="uname">
- <input type="password" name="pword" disabled="true">
- <button type="submit">Submit</button>
- </form>
-
-</div>
-
-<pre id="test">
-<script class="testbody" type="text/javascript">
-
-/** Test for Login Manager: multiple login autocomplete. **/
-
-var uname = $_(1, "uname");
-var pword = $_(1, "pword");
-const shiftModifier = SpecialPowers.Ci.nsIDOMEvent.SHIFT_MASK;
-
-// Restore the form to the default state.
-function* reinitializeForm(index) {
- // Using innerHTML is for creating the autocomplete popup again, so the
- // preference value will be applied to the constructor of
- // UserAutoCompleteResult.
- let form = document.getElementById("form" + index);
- let temp = form.innerHTML;
- form.innerHTML = "";
- form.innerHTML = temp;
-
- yield new Promise(resolve => {
- let observer = SpecialPowers.wrapCallback(() => {
- SpecialPowers.removeObserver(observer, "passwordmgr-processed-form");
- resolve();
- });
- SpecialPowers.addObserver(observer, "passwordmgr-processed-form", false);
- });
-
- yield SimpleTest.promiseFocus(window);
-
- uname = $_(index, "uname");
- pword = $_(index, "pword");
- uname.value = "";
- pword.value = "";
- pword.focus();
-}
-
-function generateDateString(date) {
- let dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
- { day: "numeric", month: "short", year: "numeric" });
- return dateAndTimeFormatter.format(date);
-}
-
-const DATE_NOW_STRING = generateDateString(new Date());
-
-// Check for expected username/password in form.
-function checkACFormPasswordField(expectedPassword) {
- var formID = uname.parentNode.id;
- is(pword.value, expectedPassword, "Checking " + formID + " password is: " + expectedPassword);
-}
-
-function spinEventLoop() {
- return Promise.resolve();
-}
-
-add_task(function* setup() {
- listenForUnexpectedPopupShown();
-});
-
-add_task(function* test_form1_initial_empty() {
- yield SimpleTest.promiseFocus(window);
-
- // Make sure initial form is empty.
- checkACFormPasswordField("");
- let popupState = yield getPopupState();
- is(popupState.open, false, "Check popup is initially closed");
-});
-
-add_task(function* test_form2_password_readonly() {
- yield SpecialPowers.pushPrefEnv({"set": [
- ["security.insecure_field_warning.contextual.enabled", true],
- ["signon.autofillForms.http", true]
- ]});
- yield reinitializeForm(2);
-
- // Trigger autocomplete popup
- doKey("down"); // open
- let popupState = yield getPopupState();
- is(popupState.open, false, "Check popup is closed for a readonly field.");
-});
-
-add_task(function* test_form3_password_disabled() {
- yield SpecialPowers.pushPrefEnv({"set": [
- ["security.insecure_field_warning.contextual.enabled", true],
- ["signon.autofillForms.http", true]
- ]});
- yield reinitializeForm(3);
-
- // Trigger autocomplete popup
- doKey("down"); // open
- let popupState = yield getPopupState();
- is(popupState.open, false, "Check popup is closed for a disabled field.");
-});
-
-add_task(function* test_form1_enabledInsecureFieldWarning_enabledInsecureAutoFillForm() {
- yield SpecialPowers.pushPrefEnv({"set": [
- ["security.insecure_field_warning.contextual.enabled", true],
- ["signon.autofillForms.http", true]
- ]});
- yield reinitializeForm(1);
- // Trigger autocomplete popup
- let shownPromise = promiseACShown();
- doKey("down"); // open
- let results = yield shownPromise;
-
- let popupState = yield getPopupState();
- is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
-
- let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
- "No username (" + DATE_NOW_STRING + ")",
- "tempuser1",
- "testuser2",
- "testuser3",
- "zzzuser4"];
- checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
-
- doKey("down"); // select insecure warning
- checkACFormPasswordField(""); // value shouldn't update just by selecting
- doKey("return"); // not "enter"!
- yield spinEventLoop(); // let focus happen
- checkACFormPasswordField("");
-});
-
-add_task(function* test_form1_disabledInsecureFieldWarning_enabledInsecureAutoFillForm() {
- yield SpecialPowers.pushPrefEnv({"set": [
- ["security.insecure_field_warning.contextual.enabled", false],
- ["signon.autofillForms.http", true]
- ]});
- yield reinitializeForm(1);
-
- // Trigger autocomplete popup
- let shownPromise = promiseACShown();
- doKey("down"); // open
- let results = yield shownPromise;
-
- let popupState = yield getPopupState();
- is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
-
- let expectedMenuItems = ["No username (" + DATE_NOW_STRING + ")",
- "tempuser1",
- "testuser2",
- "testuser3",
- "zzzuser4"];
- checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
-
- doKey("down"); // select first item
- checkACFormPasswordField(""); // value shouldn't update just by selecting
- doKey("return"); // not "enter"!
- yield spinEventLoop(); // let focus happen
- checkACFormPasswordField("user0pass");
-});
-
-add_task(function* test_form1_enabledInsecureFieldWarning_disabledInsecureAutoFillForm() {
- yield SpecialPowers.pushPrefEnv({"set": [
- ["security.insecure_field_warning.contextual.enabled", true],
- ["signon.autofillForms.http", false]
- ]});
- yield reinitializeForm(1);
-
- // Trigger autocomplete popup
- let shownPromise = promiseACShown();
- doKey("down"); // open
- let results = yield shownPromise;
-
- let popupState = yield getPopupState();
- is(popupState.selectedIndex, -1, "Check no entries are selected upon opening");
-
- let expectedMenuItems = ["This connection is not secure. Logins entered here could be compromised. Learn More",
- "No username (" + DATE_NOW_STRING + ")",
- "tempuser1",
- "testuser2",
- "testuser3",
- "zzzuser4"];
- checkArrayValues(results, expectedMenuItems, "Check all menuitems are displayed correctly.");
-
- doKey("down"); // select insecure warning
- checkACFormPasswordField(""); // value shouldn't update just by selecting
- doKey("return"); // not "enter"!
- yield spinEventLoop(); // let focus happen
- checkACFormPasswordField("");
-});
-
-add_task(function* test_form1_disabledInsecureFieldWarning_disabledInsecureAutoFillForm() {
- yield SpecialPowers.pushPrefEnv({"set": [
- ["security.insecure_field_warning.contextual.enabled", false],
- ["signon.autofillForms.http", false]
- ]});
- yield reinitializeForm(1);
-
- // Trigger autocomplete popup
- doKey("down"); // open
- let popupState = yield getPopupState();
- is(popupState.open, false, "Check popup is closed with no AutoFillForms.");
-});
-
-</script>
-</pre>
-</body>
-</html>