From 2c7880e84511edec750ded1c27b0bea5d5d3e707 Mon Sep 17 00:00:00 2001 From: Justin Dolske Date: Thu, 4 Sep 2008 13:08:57 -0700 Subject: [PATCH] Bug 361517 - Don't fill in passwords / usernames in readonly fields. r=gavin. --- .../components/passwordmgr/src/nsLoginManager.js | 8 ++ toolkit/components/passwordmgr/test/Makefile.in | 1 + .../passwordmgr/test/test_basic_form_1pw_2.html | 88 ++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 toolkit/components/passwordmgr/test/test_basic_form_1pw_2.html diff --git a/toolkit/components/passwordmgr/src/nsLoginManager.js b/toolkit/components/passwordmgr/src/nsLoginManager.js index d8d96556d..60daf7d6e 100644 --- a/toolkit/components/passwordmgr/src/nsLoginManager.js +++ b/toolkit/components/passwordmgr/src/nsLoginManager.js @@ -1002,6 +1002,14 @@ LoginManager.prototype = { if (passwordField == null) return [false, foundLogins]; + // If the fields are disabled or read-only, there's nothing to do. + if (passwordField.disabled || passwordField.readOnly || + usernameField && (usernameField.disabled || + usernameField.readOnly)) { + this.log("not filling form, login fields disabled"); + return [false, foundLogins]; + } + // If there's only a password field and it has a value, there's // nothing for us to do. (Don't clobber the existing value) if (!usernameField && passwordField.value) diff --git a/toolkit/components/passwordmgr/test/Makefile.in b/toolkit/components/passwordmgr/test/Makefile.in index a5b9f9291..36f572032 100644 --- a/toolkit/components/passwordmgr/test/Makefile.in +++ b/toolkit/components/passwordmgr/test/Makefile.in @@ -53,6 +53,7 @@ MOCHI_TESTS = \ test_basic_form_2.html \ test_basic_form_0pw.html \ test_basic_form_1pw.html \ + test_basic_form_1pw_2.html \ test_basic_form_2pw_1.html \ test_basic_form_2pw_2.html \ test_basic_form_3pw_1.html \ diff --git a/toolkit/components/passwordmgr/test/test_basic_form_1pw_2.html b/toolkit/components/passwordmgr/test/test_basic_form_1pw_2.html new file mode 100644 index 000000000..a5835ab29 --- /dev/null +++ b/toolkit/components/passwordmgr/test/test_basic_form_1pw_2.html @@ -0,0 +1,88 @@ + + + + Test for Login Manager + + + + + + +Login Manager test: forms with 1 password field, part 2 +

+ + + +
+
+
+ + + -- 2.11.4.GIT