Bug 1280294. r=MattN, a=gchang
authorMike de Boer <mdeboer@mozilla.com>
Thu, 07 Jul 2016 15:10:26 +0200
changeset 335627 781c5864339cee7aee9cac1f359b4cc3b4ed4cd5
parent 335626 2ba3feb910fb31f5fb3df3528b2991b3a37b05cf
child 335628 0f9e8e67acda1bdc44e161fc95e2a95c4c0030f2
push id1146
push userCallek@gmail.com
push dateMon, 25 Jul 2016 16:35:44 +0000
treeherdermozilla-release@a55778f9cd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, gchang
bugs1280294
milestone48.0
Bug 1280294. r=MattN, a=gchang MozReview-Commit-ID: KdN5kETA9go
toolkit/modules/sessionstore/XPathGenerator.jsm
--- a/toolkit/modules/sessionstore/XPathGenerator.jsm
+++ b/toolkit/modules/sessionstore/XPathGenerator.jsm
@@ -88,23 +88,32 @@ this.XPathGenerator = {
   },
 
   /**
    * @returns an XPath query to all savable form field nodes
    */
   get restorableFormNodes() {
     // for a comprehensive list of all available <INPUT> types see
     // http://mxr.mozilla.org/mozilla-central/search?string=kInputTypeTable
-    let ignoreTypes = ["password", "hidden", "button", "image", "submit", "reset"];
+    let ignoreInputs = new Map([
+      ["type", ["password", "hidden", "button", "image", "submit", "reset"]],
+      ["autocomplete", ["off"]]
+    ]);
     // XXXzeniko work-around until lower-case has been implemented (bug 398389)
     let toLowerCase = '"ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"';
-    let ignore = "not(translate(@type, " + toLowerCase + ")='" +
-      ignoreTypes.join("' or translate(@type, " + toLowerCase + ")='") + "')";
-    let formNodesXPath = "//textarea|//select|//xhtml:textarea|//xhtml:select|" +
-      "//input[" + ignore + "]|//xhtml:input[" + ignore + "]";
+    let ignores = [];
+    for (let [attrName, attrValues] of ignoreInputs) {
+      for (let attrValue of attrValues)
+        ignores.push(`translate(@${attrName}, ${toLowerCase})='${attrValue}'`);
+    }
+    let ignore = `not(${ignores.join(" or ")})`;
+
+    let formNodesXPath = `//textarea[${ignore}]|//xhtml:textarea[${ignore}]|` +
+      `//select[${ignore}]|//xhtml:select[${ignore}]|` +
+      `//input[${ignore}]|//xhtml:input[${ignore}]`;
 
     // Special case for about:config's search field.
     formNodesXPath += '|/xul:window[@id="config"]//xul:textbox[@id="textbox"]';
 
     delete this.restorableFormNodes;
     return (this.restorableFormNodes = formNodesXPath);
   }
 };