Bug 525113: Form Fill UI: Does not recognize multiple fields in Yahoo Login [r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Thu, 29 Oct 2009 13:09:22 -0400
changeset 1050 06fd1784a33fc9c58739a206a679fe076e950874
parent 1049 0d0aba4a33554149445aad3ae70e1873c311dde5
child 1051 2b0927e6322c09faa0bdaf7f438084b3fd02a344
push id920
push usermfinkle@mozilla.com
push dateThu, 29 Oct 2009 17:09:31 +0000
reviewersmark.finkle
bugs525113
Bug 525113: Form Fill UI: Does not recognize multiple fields in Yahoo Login [r=mark.finkle]
chrome/content/browser-ui.js
--- a/chrome/content/browser-ui.js
+++ b/chrome/content/browser-ui.js
@@ -1065,28 +1065,38 @@ var FormHelper = {
 
     return false;
   },
 
   _isValidSelectElement: function(aElement) {
     return (aElement instanceof HTMLSelectElement) || (aElement instanceof Ci.nsIDOMXULMenuListElement);
   },
 
+
+  _nsResolver: function(aPrefix) {
+    var ns = {
+      "xhtml" : "http://www.w3.org/1999/xhtml"
+    };
+    return ns[aPrefix] || null;
+  },
+
   _getAll: function() {
     let doc = getBrowser().contentDocument;
-    let nodes = doc.evaluate("//input|//select",
+    let prefix = doc.documentElement.wrappedJSObject.namespaceURI ? "xhtml" : "";
+    let expression = "//input|//select|//button".replace("//", "//" + prefix + ":");
+    let nodes = doc.evaluate(expression,
                              doc,
-                             null,
+                             this._nsResolver,
                              XPathResult.ORDERED_NODE_ITERATOR_TYPE,
                              null);
 
     let elements = [];
     let node = nodes.iterateNext();
     while (node) {
-      if (this._isValidElement(node)) 
+      if (this._isValidElement(node))
         elements.push(node);
       node = nodes.iterateNext();
     }
 
     function orderByTabIndex(a, b) {
       return a.tabIndex - b.tabIndex;
     }
     return elements.sort(orderByTabIndex);