Bug 1280294. r=MattN, a=gchang
authorMike de Boer <mdeboer@mozilla.com>
Thu, 07 Jul 2016 15:10:26 +0200
changeset 339948 6484e936f2c297f7c3c00b98ccf79fbdebef7686
parent 339947 6463668502ef149019aa87b6175c86eaee30403a
child 339949 f3e298bcd505bd69c8302d3bbb9e4ed4d5c1988d
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, gchang
bugs1280294
milestone49.0a2
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);
   }
 };