summaryrefslogtreecommitdiffstats
path: root/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html')
-rw-r--r--toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html218
1 files changed, 0 insertions, 218 deletions
diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
deleted file mode 100644
index 7d5725322..000000000
--- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html
+++ /dev/null
@@ -1,218 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <meta charset="utf-8">
- <title>Test autocomplete on an HTTPS page using upgraded HTTP 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>
-<script>
-const chromeScript = runChecksAfterCommonInit(false);
-
-runInParent(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.
- let nsLoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
- Ci.nsILoginInfo, "init");
-
- // We have two actual HTTPS to avoid autofill before the schemeUpgrades pref flips to true.
- let login0 = new nsLoginInfo("https://example.org", "https://example.org", null,
- "name", "pass", "uname", "pword");
-
- let login1 = new nsLoginInfo("https://example.org", "https://example.org", null,
- "name1", "pass1", "uname", "pword");
-
- // Same as above but HTTP instead of HTTPS (to test de-duping)
- let login2 = new nsLoginInfo("http://example.org", "http://example.org", null,
- "name1", "passHTTP", "uname", "pword");
-
- // Different HTTP login to upgrade with secure formSubmitURL
- let login3 = new nsLoginInfo("http://example.org", "https://example.org", null,
- "name2", "passHTTPtoHTTPS", "uname", "pword");
-
- try {
- Services.logins.addLogin(login0);
- Services.logins.addLogin(login1);
- Services.logins.addLogin(login2);
- Services.logins.addLogin(login3);
- } 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">
- <iframe src="https://example.org/tests/toolkit/components/passwordmgr/test/mochitest/form_basic.html"></iframe>
-</div>
-
-<pre id="test">
-<script class="testbody" type="text/javascript">
-const shiftModifier = SpecialPowers.Ci.nsIDOMEvent.SHIFT_MASK;
-
-let iframe = SpecialPowers.wrap(document.getElementsByTagName("iframe")[0]);
-let iframeDoc;
-let uname;
-let pword;
-
-// Restore the form to the default state.
-function restoreForm() {
- pword.focus();
- uname.value = "";
- pword.value = "";
- uname.focus();
-}
-
-// Check for expected username/password in form.
-function checkACForm(expectedUsername, expectedPassword) {
- let formID = uname.parentNode.id;
- is(uname.value, expectedUsername, "Checking " + formID + " username");
- is(pword.value, expectedPassword, "Checking " + formID + " password");
-}
-
-add_task(function* setup() {
- yield SpecialPowers.pushPrefEnv({"set": [["signon.schemeUpgrades", true]]});
-
- yield new Promise(resolve => {
- iframe.addEventListener("load", function onLoad() {
- iframe.removeEventListener("load", onLoad);
- resolve();
- });
- });
-
- iframeDoc = iframe.contentDocument;
- uname = iframeDoc.getElementById("form-basic-username");
- pword = iframeDoc.getElementById("form-basic-password");
-});
-
-add_task(function* test_empty_first_entry() {
- // 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", "name1", "name2"], "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("name1", "pass1");
-});
-
-add_task(function* test_search() {
- restoreForm();
- let shownPromise = promiseACShown();
- // We need to blur for the autocomplete controller to notice the forced value below.
- uname.blur();
- uname.value = "name";
- uname.focus();
- sendChar("1");
- doKey("down"); // open
- let results = yield shownPromise;
- checkArrayValues(results, ["name1"], "check result deduping for 'name1'");
- doKey("down"); // first
- doKey("return"); // not "enter"!
- yield promiseFormsProcessed();
- checkACForm("name1", "pass1");
-
- let popupState = yield getPopupState();
- is(popupState.open, false, "Check popup is now closed");
-});
-
-add_task(function* test_delete_first_entry() {
- restoreForm();
- uname.focus();
- let shownPromise = promiseACShown();
- doKey("down");
- yield shownPromise;
-
- let index0Promise = notifySelectedIndex(0);
- doKey("down");
- yield index0Promise;
-
- let deletionPromise = promiseStorageChanged(["removeLogin"]);
- // On OS X, shift-backspace and shift-delete work, just delete does not.
- // On Win/Linux, shift-backspace does not work, delete and shift-delete do.
- doKey("delete", shiftModifier);
- yield deletionPromise;
- checkACForm("", "");
-
- let results = yield notifyMenuChanged(2, "name1");
-
- checkArrayValues(results, ["name1", "name2"], "two should remain after deleting the first");
- let popupState = yield getPopupState();
- is(popupState.open, true, "Check popup stays open after deleting");
- doKey("escape");
- popupState = yield getPopupState();
- is(popupState.open, false, "Check popup closed upon ESC");
-});
-
-add_task(function* test_delete_duplicate_entry() {
- restoreForm();
- uname.focus();
- let shownPromise = promiseACShown();
- doKey("down");
- yield shownPromise;
-
- let index0Promise = notifySelectedIndex(0);
- doKey("down");
- yield index0Promise;
-
- let deletionPromise = promiseStorageChanged(["removeLogin"]);
- // On OS X, shift-backspace and shift-delete work, just delete does not.
- // On Win/Linux, shift-backspace does not work, delete and shift-delete do.
- doKey("delete", shiftModifier);
- yield deletionPromise;
- checkACForm("", "");
-
- is(LoginManager.countLogins("http://example.org", "http://example.org", null), 1,
- "Check that the HTTP login remains");
- is(LoginManager.countLogins("https://example.org", "https://example.org", null), 0,
- "Check that the HTTPS login was deleted");
-
- // Two menu items should remain as the HTTPS login should have been deleted but
- // the HTTP would remain.
- let results = yield notifyMenuChanged(1, "name2");
-
- checkArrayValues(results, ["name2"], "one should remain after deleting the HTTPS name1");
- let popupState = yield getPopupState();
- is(popupState.open, true, "Check popup stays open after deleting");
- doKey("escape");
- popupState = yield getPopupState();
- is(popupState.open, false, "Check popup closed upon ESC");
-});
-
-</script>
-</pre>
-</body>
-</html>