From 406f121ef56185544d9d8c1fbd5561bb81760076 Mon Sep 17 00:00:00 2001 From: Justin Dolske Date: Mon, 16 Dec 2013 13:27:47 -0800 Subject: [PATCH] Bug 946549 - Remove dead code obsoleted by bug 355063 for filling passwords on load. r=MattN --- browser/base/content/content.js | 3 - .../base/content/contenthandlers/Content.js | 1 - mobile/android/chrome/content/browser.js | 2 - modules/libpref/src/init/all.js | 1 - .../passwordmgr/LoginManagerContent.jsm | 111 ------------------ .../components/passwordmgr/test/mochitest.ini | 3 - .../test/test_basic_form_pwevent.html | 20 ++-- .../passwordmgr/test/test_maxforms_1.html | 64 ---------- .../passwordmgr/test/test_maxforms_2.html | 64 ---------- .../passwordmgr/test/test_maxforms_3.html | 64 ---------- 10 files changed, 8 insertions(+), 325 deletions(-) delete mode 100644 toolkit/components/passwordmgr/test/test_maxforms_1.html delete mode 100644 toolkit/components/passwordmgr/test/test_maxforms_2.html delete mode 100644 toolkit/components/passwordmgr/test/test_maxforms_3.html diff --git a/browser/base/content/content.js b/browser/base/content/content.js index a3ac1bdee42..98499e06a31 100644 --- a/browser/base/content/content.js +++ b/browser/base/content/content.js @@ -38,9 +38,6 @@ if (Services.prefs.getBoolPref("browser.tabs.remote")) { sendAsyncMessage("contextmenu", {}, { event: event }); }, false); } else { - addEventListener("DOMContentLoaded", function(event) { - LoginManagerContent.onContentLoaded(event); - }); addEventListener("DOMFormHasPassword", function(event) { InsecurePasswordUtils.checkForInsecurePasswords(event.target); LoginManagerContent.onFormPassword(event); diff --git a/browser/metro/base/content/contenthandlers/Content.js b/browser/metro/base/content/contenthandlers/Content.js index b7692b1a40b..f7f5b718668 100644 --- a/browser/metro/base/content/contenthandlers/Content.js +++ b/browser/metro/base/content/contenthandlers/Content.js @@ -199,7 +199,6 @@ let Content = { break; case "DOMContentLoaded": - LoginManagerContent.onContentLoaded(aEvent); this._maybeNotifyErrorPage(); break; diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index a12975b033e..a38e1bdbc0f 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -3368,8 +3368,6 @@ Tab.prototype = { case "DOMContentLoaded": { let target = aEvent.originalTarget; - LoginManagerContent.onContentLoaded(aEvent); - // ignore on frames and other documents if (target != this.browser.contentDocument) return; diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index bc7e5511bef..56336376fbf 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -3897,7 +3897,6 @@ pref("signon.rememberSignons", true); pref("signon.autofillForms", true); pref("signon.autologin.proxy", false); pref("signon.debug", false); -pref("signon.useDOMFormHasPassword", true); // Satchel (Form Manager) prefs pref("browser.formfill.debug", false); diff --git a/toolkit/components/passwordmgr/LoginManagerContent.jsm b/toolkit/components/passwordmgr/LoginManagerContent.jsm index f22bacf9bee..50ac2b42ca0 100644 --- a/toolkit/components/passwordmgr/LoginManagerContent.jsm +++ b/toolkit/components/passwordmgr/LoginManagerContent.jsm @@ -14,7 +14,6 @@ Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); var gEnabled = false, gDebug = false, gAutofillForms = true; // these mirror signon.* prefs -var gUseDOMFormHasPassword = false; // use DOMFormHasPassword event for autofill function log(...pieces) { function generateLogMessage(args) { @@ -72,7 +71,6 @@ var observer = { gDebug = Services.prefs.getBoolPref("signon.debug"); gEnabled = Services.prefs.getBoolPref("signon.rememberSignons"); gAutofillForms = Services.prefs.getBoolPref("signon.autofillForms"); - gUseDOMFormHasPassword = Services.prefs.getBoolPref("signon.useDOMFormHasPassword"); }, }; @@ -94,32 +92,8 @@ var LoginManagerContent = { return this.__formFillService; }, - onContentLoaded : function (event) { - // If we're using the new DOMFormHasPassword event, don't fill at pageload. - if (gUseDOMFormHasPassword) - return; - - if (!event.isTrusted) - return; - - if (!gEnabled) - return; - - let domDoc = event.target; - - // Only process things which might have HTML forms. - if (!(domDoc instanceof Ci.nsIDOMHTMLDocument)) - return; - - this._fillDocument(domDoc); - }, - onFormPassword: function (event) { - // If we're not using the new DOMFormHasPassword event, only fill at pageload. - if (!gUseDOMFormHasPassword) - return; - if (!event.isTrusted) return; @@ -552,91 +526,6 @@ var LoginManagerContent = { }, - /* - * _fillDocument - * - * Called when a page has loaded. For each form in the document, - * we check to see if it can be filled with a stored login. - */ - _fillDocument : function (doc) { - var forms = doc.forms; - if (!forms || forms.length == 0) - return; - - var formOrigin = LoginUtils._getPasswordOrigin(doc.documentURI); - - // If there are no logins for this site, bail out now. - if (!Services.logins.countLogins(formOrigin, "", null)) - return; - - // If we're currently displaying a master password prompt, defer - // processing this document until the user handles the prompt. - if (Services.logins.uiBusy) { - log("deferring fillDoc for", doc.documentURI); - let self = this; - let observer = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, Ci.nsISupportsWeakReference]), - - observe: function (subject, topic, data) { - log("Got deferred fillDoc notification:", topic); - // Only run observer once. - Services.obs.removeObserver(this, "passwordmgr-crypto-login"); - Services.obs.removeObserver(this, "passwordmgr-crypto-loginCanceled"); - if (topic == "passwordmgr-crypto-loginCanceled") - return; - self._fillDocument(doc); - }, - handleEvent : function (event) { - // Not expected to be called - } - }; - // Trickyness follows: We want an observer, but don't want it to - // cause leaks. So add the observer with a weak reference, and use - // a dummy event listener (a strong reference) to keep it alive - // until the document is destroyed. - Services.obs.addObserver(observer, "passwordmgr-crypto-login", true); - Services.obs.addObserver(observer, "passwordmgr-crypto-loginCanceled", true); - doc.addEventListener("mozCleverClosureHack", observer); - return; - } - - log("fillDocument processing", forms.length, "forms on", doc.documentURI); - - var autofillForm = gAutofillForms && !PrivateBrowsingUtils.isWindowPrivate(doc.defaultView); - var previousActionOrigin = null; - var foundLogins = null; - - // Limit the number of forms we try to fill. If there are too many - // forms, just fill some at the beginning and end of the page. - const MAX_FORMS = 40; // assumed to be an even number - var skip_from = -1, skip_to = -1; - if (forms.length > MAX_FORMS) { - log("fillDocument limiting number of forms filled to", MAX_FORMS); - let chunk_size = MAX_FORMS / 2; - skip_from = chunk_size; - skip_to = forms.length - chunk_size; - } - - for (var i = 0; i < forms.length; i++) { - // Skip some in the middle of the document if there were too many. - if (i == skip_from) - i = skip_to; - - var form = forms[i]; - - // Only the actionOrigin might be changing, so if it's the same - // as the last form on the page we can reuse the same logins. - var actionOrigin = LoginUtils._getActionOrigin(form); - if (actionOrigin != previousActionOrigin) { - foundLogins = null; - previousActionOrigin = actionOrigin; - } - log("_fillDocument processing form[", i, "]"); - foundLogins = this._fillForm(form, autofillForm, false, false, foundLogins)[1]; - } // foreach form - }, - - /* * _fillform * diff --git a/toolkit/components/passwordmgr/test/mochitest.ini b/toolkit/components/passwordmgr/test/mochitest.ini index 1fdcba64748..72c8d078cad 100644 --- a/toolkit/components/passwordmgr/test/mochitest.ini +++ b/toolkit/components/passwordmgr/test/mochitest.ini @@ -54,9 +54,6 @@ support-files = # Bug 917797 - too many intermittent failures skip-if = true [test_master_password_cleanup.html] -[test_maxforms_1.html] -[test_maxforms_2.html] -[test_maxforms_3.html] [test_notifications.html] [test_notifications_popup.html] skip-if = os == "linux" # bug 934057 diff --git a/toolkit/components/passwordmgr/test/test_basic_form_pwevent.html b/toolkit/components/passwordmgr/test/test_basic_form_pwevent.html index 611945cb978..e0b51f2e53c 100644 --- a/toolkit/components/passwordmgr/test/test_basic_form_pwevent.html +++ b/toolkit/components/passwordmgr/test/test_basic_form_pwevent.html @@ -34,19 +34,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=355063 SimpleTest.finish(); } - if (SpecialPowers.getBoolPref("signon.useDOMFormHasPassword")) { - commonInit(); + commonInit(); - // Password Manager's own listener should always have been added first, so - // the test's listener should be called after the pwmgr's listener fills in - // a login. - // - SpecialPowers.addChromeEventListener("DOMFormHasPassword", checkForm); - window.addEventListener("load", startTest); - SimpleTest.waitForExplicitFinish(); - } else { - ok(true, "Skipping test when useDOMFormHasPassword is disabled"); - } + // Password Manager's own listener should always have been added first, so + // the test's listener should be called after the pwmgr's listener fills in + // a login. + // + SpecialPowers.addChromeEventListener("DOMFormHasPassword", checkForm); + window.addEventListener("load", startTest); + SimpleTest.waitForExplicitFinish(); diff --git a/toolkit/components/passwordmgr/test/test_maxforms_1.html b/toolkit/components/passwordmgr/test/test_maxforms_1.html deleted file mode 100644 index bcc2e29660c..00000000000 --- a/toolkit/components/passwordmgr/test/test_maxforms_1.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - Test for Login Manager - - - - - -Test limiting number of forms filled. - -

- - - - - -
-
-
- - diff --git a/toolkit/components/passwordmgr/test/test_maxforms_2.html b/toolkit/components/passwordmgr/test/test_maxforms_2.html deleted file mode 100644 index da315c42029..00000000000 --- a/toolkit/components/passwordmgr/test/test_maxforms_2.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - Test for Login Manager - - - - - -Test limiting number of forms filled. - -

- - - - - -
-
-
- - diff --git a/toolkit/components/passwordmgr/test/test_maxforms_3.html b/toolkit/components/passwordmgr/test/test_maxforms_3.html deleted file mode 100644 index 63d2bfedd49..00000000000 --- a/toolkit/components/passwordmgr/test/test_maxforms_3.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - Test for Login Manager - - - - - -Test limiting number of forms filled. - -

- - - - - -
-
-
- -