Bug 1361220 - Remove browser.formfill.saveHttpsForms support. r=mattn draft
authorJonathan Guillotte-Blouin <jguillotteblouin@mozilla.com>
Wed, 10 May 2017 13:48:33 -0700
changeset 576594 896539ae9680fb4c54fd5fe3817455aaa00298b2
parent 576334 3b96f277325747fe668ca8cd896d2f581238e4ee
child 628256 f5f7354f524bef10ea2f1efffe96037b0b17f350
push id58427
push userbmo:jguillotteblouin@mozilla.com
push dateThu, 11 May 2017 23:17:52 +0000
reviewersmattn
bugs1361220
milestone55.0a1
Bug 1361220 - Remove browser.formfill.saveHttpsForms support. r=mattn MozReview-Commit-ID: 3c1oDYnz3KC
modules/libpref/init/all.js
toolkit/components/satchel/formSubmitListener.js
toolkit/components/satchel/test/subtst_form_submission_1.html
toolkit/components/satchel/test/test_form_submission.html
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4444,17 +4444,16 @@ pref("signon.recipes.path",             
 pref("signon.schemeUpgrades",               false);
 // This temporarily prevents the master password to reprompt for autocomplete.
 pref("signon.masterPasswordReprompt.timeout_ms", 900000); // 15 Minutes
 
 // Satchel (Form Manager) prefs
 pref("browser.formfill.debug",            false);
 pref("browser.formfill.enable",           true);
 pref("browser.formfill.expire_days",      180);
-pref("browser.formfill.saveHttpsForms",   true);
 pref("browser.formfill.agedWeight",       2);
 pref("browser.formfill.bucketSize",       1);
 pref("browser.formfill.maxTimeGroupings", 25);
 pref("browser.formfill.timeGroupingSize", 604800);
 pref("browser.formfill.boundaryWeight",   25);
 pref("browser.formfill.prefixWeight",     5);
 
 // Zoom prefs
--- a/toolkit/components/satchel/formSubmitListener.js
+++ b/toolkit/components/satchel/formSubmitListener.js
@@ -15,29 +15,27 @@ Components.utils.import("resource://gre/
 
 var satchelFormListener = {
     QueryInterface: XPCOMUtils.generateQI([Ci.nsIFormSubmitObserver,
                                            Ci.nsIObserver,
                                            Ci.nsISupportsWeakReference]),
 
     debug: true,
     enabled: true,
-    saveHttpsForms: true,
 
     init() {
         Services.obs.addObserver(this, "earlyformsubmit");
         Services.obs.addObserver(this, "xpcom-shutdown");
         Services.prefs.addObserver("browser.formfill.", this);
         this.updatePrefs();
     },
 
     updatePrefs() {
         this.debug          = Services.prefs.getBoolPref("browser.formfill.debug");
         this.enabled        = Services.prefs.getBoolPref("browser.formfill.enable");
-        this.saveHttpsForms = Services.prefs.getBoolPref("browser.formfill.saveHttpsForms");
     },
 
     // Implements the Luhn checksum algorithm as described at
     // http://wikipedia.org/wiki/Luhn_algorithm
     isValidCCNumber(ccNumber) {
         // Remove dashes and whitespace
         ccNumber = ccNumber.replace(/[\-\s]/g, "");
 
@@ -90,23 +88,16 @@ var satchelFormListener = {
             if (!this.enabled)
                 return;
 
             if (PrivateBrowsingUtils.isContentWindowPrivate(domWin))
                 return;
 
             this.log("Form submit observer notified.");
 
-            if (!this.saveHttpsForms) {
-                if (actionURI.schemeIs("https"))
-                    return;
-                if (form.ownerDocument.documentURIObject.schemeIs("https"))
-                    return;
-            }
-
             if (form.hasAttribute("autocomplete") &&
                 form.getAttribute("autocomplete").toLowerCase() == "off")
                 return;
 
             let entries = [];
             for (let i = 0; i < form.elements.length; i++) {
                 let input = form.elements[i];
                 if (!(input instanceof Ci.nsIDOMHTMLInputElement))
--- a/toolkit/components/satchel/test/subtst_form_submission_1.html
+++ b/toolkit/components/satchel/test/subtst_form_submission_1.html
@@ -1,37 +1,29 @@
 <!DOCTYPE HTML>
 <html>
 
 <head>
 </head>
 
 <body>
 
-<form id="subform1" onsubmit="return checkSubmit(21)">
-  <input id="subtest1" type="text" name="subtest1">
-  <button type="submit">Submit</button>
-</form>
-
 <form id="subform2" onsubmit="return checkSubmit(100)">
   <input id="subtest2" type="text" name="subtest2">
   <button type="submit">Submit</button>
 </form>
 
 <script>
   function checkSubmit(num) {
     return SpecialPowers.wrap(parent).wrappedJSObject.checkSubmit(num);
   }
 
   function clickButton(num) {
-    if (num == 21)
+    if (num == 100)
       document.querySelectorAll("button")[0].click();
-    else if (num == 100)
-      document.querySelectorAll("button")[1].click();
   }
 
   // set the input's value (can't use a default value, as satchel will ignore it)
-  document.getElementById("subtest1").value = "subtestValue";
   document.getElementById("subtest2").value = "subtestValue";
 </script>
 
 </body>
 </html>
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -137,39 +137,31 @@
   </form>
 
   <!-- input with sensitive data (15 digit whitespace-separated credit card number) -->
   <form id="form19" onsubmit="return checkSubmit(19)">
     <input type="text" name="test1">
     <button type="submit">Submit</button>
   </form>
 
-  <!-- form data submitted through HTTPS, when browser.formfill.saveHttpsForms is false -->
-  <form id="form20" action="https://www.example.com/" onsubmit="return checkSubmit(20)">
-    <input type="text" name="test1">
-    <button type="submit">Submit</button>
-  </form>
-
-  <!-- Form 21 is submitted into an iframe, not declared here. -->
-
   <!-- Don't save values if the form is invalid. -->
-  <form id="form22" onsubmit="return checkSubmit(22);">
-    <input type='email' name='test1' oninvalid="return checkSubmit(22);">
+  <form id="form20" onsubmit="return checkSubmit(20);">
+    <input type='email' name='test1' oninvalid="return checkSubmit(20);">
     <button type='submit'>Submit</button>
   </form>
 
   <!-- Don't save values if the form is invalid. -->
-  <form id="form23" onsubmit="return checkSubmit(23);">
-    <input type='email' value='foo' oninvalid="return checkSubmit(23);">
+  <form id="form21" onsubmit="return checkSubmit(21);">
+    <input type='email' value='foo' oninvalid="return checkSubmit(21);">
     <input type='text' name='test1'>
     <button type='submit'>Submit</button>
   </form>
 
   <!-- Don't save values if the input name is 'searchbar-history' -->
-  <form id="form24" onsubmit="return checkSubmit(24);">
+  <form id="form22" onsubmit="return checkSubmit(22);">
     <input type='text' name='searchbar-history'>
     <button type='submit'>Submit</button>
   </form>
 
   <!-- ===== Things that should be saved ===== -->
 
   <!-- Form 100 is submitted into an iframe, not declared here. -->
 
@@ -241,22 +233,16 @@
   </form>
 
   <!-- form data submitted through HTTPS, when browser.formfill.saveHttpsForms is true -->
   <form id="form109" action="https://www.example.com/" onsubmit="return checkSubmit(109)">
     <input type="text" name="test9">
     <button type="submit">Submit</button>
   </form>
 
-  <!-- regular form data, when browser.formfill.saveHttpsForms is false -->
-  <form id="form110" onsubmit="return checkSubmit(110)">
-    <input type="text" name="test10">
-    <button type="submit">Submit</button>
-  </form>
-
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 /* import-globals-from satchel_common.js */
 var numSubmittedForms = 0;
 
 var ccNumbers = {
   valid15: [
@@ -328,19 +314,18 @@ function startTest() {
   testData = ccNumbers.valid15;
   for (let i = 0; i != testData.length; i++) {
     $_(16, "test" + (i + 1)).value = testData[i];
   }
   $_(17, "test1").value = "001064088";
   $_(18, "test1").value = "0000-0000-0080-4609";
   $_(19, "test1").value = "0000 0000 0222 331";
   $_(20, "test1").value = "dontSaveThis";
-  $_(22, "test1").value = "dontSaveThis";
-  $_(23, "test1").value = "dontSaveThis";
-  $_(24, "searchbar-history").value = "dontSaveThis";
+  $_(21, "test1").value = "dontSaveThis";
+  $_(22, "searchbar-history").value = "dontSaveThis";
 
   $_(101, "test1").value = "savedValue";
   $_(102, "test2").value = "savedValue";
   $_(103, "test3").value = "savedValue";
   $_(104, "test4").value = " trimTrailingAndLeadingSpace ";
   $_(105, "test5").value = "\t trimTrailingAndLeadingWhitespace\t ";
   $_(106, "test6").value = "00000000109181";
 
@@ -350,17 +335,16 @@ function startTest() {
   }
 
   testData = ccNumbers.invalid15;
   for (let i = 0; i != testData.length; i++) {
     $_(108, "test8_" + (i + 1)).value = testData[i];
   }
 
   $_(109, "test9").value = "savedValue";
-  $_(110, "test10").value = "savedValue";
 
   // submit the first form.
   var button = getFormSubmitButton(1);
   button.click();
 }
 
 
 // Called by each form's onsubmit handler.
@@ -389,18 +373,16 @@ function checkSubmit(formNum) {
     case 15:
     case 16:
     case 17:
     case 18:
     case 19:
     case 20:
     case 21:
     case 22:
-    case 23:
-    case 24:
       countEntries(null, null,
         function(num) {
           ok(!num, "checking for empty storage");
           submitForm(formNum);
         });
         return false;
     case 100:
         checkForSave("subtest2", "subtestValue", "checking saved subtest value");
@@ -431,79 +413,60 @@ function checkSubmit(formNum) {
     case 108:
         for (let i = 0; i != ccNumbers.invalid15.length; i++) {
           checkForSave("test8_" + (i + 1), ccNumbers.invalid15[i], "checking saved value");
         }
         break;
     case 109:
         checkForSave("test9", "savedValue", "checking saved value");
         break;
-    case 110:
-        checkForSave("test10", "savedValue", "checking saved value");
-        break;
     default:
         ok(false, "Unexpected form submission");
         break;
   }
 
   return submitForm(formNum);
 }
 
 function submitForm(formNum) {
-  // Forms 20 and 21 requires browser.formfill.saveHttpsForms to be false
-  if (formNum == 19)
-    SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", false);
-  // Reset preference now that 20 and 21 are over
-  if (formNum == 21)
-    SpecialPowers.clearUserPref("browser.formfill.saveHttpsForms");
-
   // End the test now on SeaMonkey.
-  if (formNum == 21 && navigator.userAgent.match(/ SeaMonkey\//)) {
+  if (formNum == 20 && navigator.userAgent.match(/ SeaMonkey\//)) {
     checkObserver.uninit();
-    is(numSubmittedForms, 21, "Ensuring all forms were submitted.");
+    is(numSubmittedForms, 20, "Ensuring all forms were submitted.");
 
     todo(false, "Skipping remaining checks on SeaMonkey ftb. (Bug 589471)");
     // finish(), yet let the test actually end first, to be safe.
     SimpleTest.executeSoon(SimpleTest.finish);
 
     return false; // return false to cancel current form submission
   }
 
-  // Form 109 requires browser.formfill.save_https_forms to be true;
-  // Form 110 requires it to be false.
-  if (formNum == 108)
-    SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", true);
-  if (formNum == 109)
-    SpecialPowers.setBoolPref("browser.formfill.saveHttpsForms", false);
-  if (formNum == 110)
-    SpecialPowers.clearUserPref("browser.formfill.saveHttpsForms");
-
   // End the test at the last form.
-  if (formNum == 110) {
-    is(numSubmittedForms, 35, "Ensuring all forms were submitted.");
+  if (formNum == 109) {
+    is(numSubmittedForms, 32, "Ensuring all forms were submitted.");
     checkObserver.uninit();
-    SimpleTest.finish();
+    SimpleTest.executeSoon(SimpleTest.finish);
     return false; // return false to cancel current form submission
   }
 
   // This timeout is here so that button.click() is never called before this
   // function returns. If button.click() is called before returning, a long
   // chain of submits will happen recursively since the submit is dispatched
   // immediately.
   //
   // This in itself is fine, but if there are errors in the code, mochitests
   // will in some cases give you "server too busy", which is hard to debug!
   //
   setTimeout(function() {
     checkObserver.waitForChecks(function() {
-      var nextFormNum = formNum == 24 ? 100 : (formNum + 1);
+      var nextFormNum = formNum == 22 ? 100 : (formNum + 1);
 
       // Submit the next form. Special cases are Forms 21 and 100, which happen
       // from an HTTPS domain in an iframe.
-      if (nextFormNum == 21 || nextFormNum == 100) {
+      if (nextFormNum == 100) {
         ok(true, "submitting iframe test " + nextFormNum);
         SpecialPowers.wrap(document.getElementById("iframe").contentWindow).wrappedJSObject.clickButton(nextFormNum);
       } else {
         var button = getFormSubmitButton(nextFormNum);
         button.click();
       }
     });
   }, 0);