Bug 1510470 - Disable OS re-auth for credit cards by default. r=timdream
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 28 Nov 2018 01:08:35 +0000
changeset 448468 75d25888cc9186e1f5c0f1dfa613c4c5ad846b43
parent 448467 b99cfc042c4f45b6adb6f6d57ca4efcfa6d6d1a6
child 448469 0dd1b93495d527f6a9faa9606e2c1fd295a9eb2f
push id35114
push usernbeleuzu@mozilla.com
push dateWed, 28 Nov 2018 09:51:41 +0000
treeherdermozilla-central@9234dc84cd93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimdream
bugs1510470
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1510470 - Disable OS re-auth for credit cards by default. r=timdream Differential Revision: https://phabricator.services.mozilla.com/D13169
browser/app/profile/firefox.js
browser/components/payments/test/browser/browser.ini
browser/extensions/formautofill/OSKeyStore.jsm
browser/extensions/formautofill/test/browser/browser.ini
browser/extensions/formautofill/test/mochitest/mochitest.ini
browser/extensions/formautofill/test/unit/test_osKeyStore.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1702,16 +1702,18 @@ pref("extensions.formautofill.creditCard
 // 0: none
 // 1: submitted a manually-filled credit card form (but didn't see the doorhanger
 //    because of a duplicate profile in the storage)
 // 2: saw the doorhanger
 // 3: submitted an autofill'ed credit card form
 pref("extensions.formautofill.creditCards.used", 0);
 pref("extensions.formautofill.firstTimeUse", true);
 pref("extensions.formautofill.heuristics.enabled", true);
+// Whether the user enabled the OS re-auth dialog.
+pref("extensions.formautofill.reauth.enabled", false);
 pref("extensions.formautofill.section.enabled", true);
 pref("extensions.formautofill.loglevel", "Warn");
 
 #ifdef NIGHTLY_BUILD
 // Comma separated list of countries Form Autofill is available in.
 pref("extensions.formautofill.supportedCountries", "US,CA,DE");
 pref("extensions.formautofill.supportRTL", true);
 #else
--- a/browser/components/payments/test/browser/browser.ini
+++ b/browser/components/payments/test/browser/browser.ini
@@ -1,14 +1,15 @@
 [DEFAULT]
 head = head.js
 prefs =
   browser.pagethumbnails.capturing_disabled=true
   dom.payments.request.enabled=true
   extensions.formautofill.creditCards.available=true
+  extensions.formautofill.reauth.enabled=true
 skip-if = !e10s # Bug 1365964 - Payment Request isn't implemented for non-e10s
 support-files =
   blank_page.html
 
 [browser_address_edit.js]
 skip-if = verify && debug && os == 'mac'
 [browser_address_edit_hidden_fields.js]
 [browser_card_edit.js]
--- a/browser/extensions/formautofill/OSKeyStore.jsm
+++ b/browser/extensions/formautofill/OSKeyStore.jsm
@@ -104,17 +104,17 @@ var OSKeyStore = {
       log.debug("ensureLoggedIn: Has a pending unlock operation");
       return this._pendingUnlockPromise;
     }
     log.debug("ensureLoggedIn: Creating new pending unlock promise. reauth: ", reauth);
 
     let unlockPromise;
 
     // Decides who should handle reauth
-    if (typeof reauth == "boolean" && !reauth) {
+    if (!this._reauthEnabledByUser || (typeof reauth == "boolean" && !reauth)) {
       unlockPromise = Promise.resolve();
     } else if (!AppConstants.MOZILLA_OFFICIAL && this._testReauth) {
       unlockPromise = this._reauthInTests();
     } else if (AppConstants.platform == "win" ||
                AppConstants.platform == "macosx") {
       let reauthLabel = typeof reauth == "string" ? reauth : "";
       // On Windows, this promise rejects when the user cancels login dialog, see bug 1502121.
       // On macOS this resolves to false, so we would need to check it.
@@ -247,8 +247,10 @@ XPCOMUtils.defineLazyGetter(this, "log",
   let ConsoleAPI = ChromeUtils.import("resource://gre/modules/Console.jsm", {}).ConsoleAPI;
   return new ConsoleAPI({
     maxLogLevelPref: "extensions.formautofill.loglevel",
     prefix: "OSKeyStore",
   });
 });
 
 XPCOMUtils.defineLazyPreferenceGetter(OSKeyStore, "_testReauth", TEST_ONLY_REAUTH, "");
+XPCOMUtils.defineLazyPreferenceGetter(OSKeyStore, "_reauthEnabledByUser",
+                                      "extensions.formautofill.reauth.enabled", false);
--- a/browser/extensions/formautofill/test/browser/browser.ini
+++ b/browser/extensions/formautofill/test/browser/browser.ini
@@ -1,12 +1,13 @@
 [DEFAULT]
 head = head.js
 prefs =
   extensions.formautofill.creditCards.available=true
+  extensions.formautofill.reauth.enabled=true
 support-files =
   ../fixtures/autocomplete_basic.html
   ../fixtures/autocomplete_simple_basic.html
   ../fixtures/autocomplete_creditcard_basic.html
 
 [browser_autocomplete_footer.js]
 skip-if = verify
 [browser_autocomplete_marked_back_forward.js]
--- a/browser/extensions/formautofill/test/mochitest/mochitest.ini
+++ b/browser/extensions/formautofill/test/mochitest/mochitest.ini
@@ -1,11 +1,12 @@
 [DEFAULT]
 prefs =
   extensions.formautofill.creditCards.available=true
+  extensions.formautofill.reauth.enabled=true
 support-files =
   ../../../../../toolkit/components/satchel/test/satchel_common.js
   ../../../../../toolkit/components/satchel/test/parent_utils.js
   formautofill_common.js
   formautofill_parent_utils.js
 
 [test_address_level_1_submission.html]
 [test_autofocus_form.html]
--- a/browser/extensions/formautofill/test/unit/test_osKeyStore.js
+++ b/browser/extensions/formautofill/test/unit/test_osKeyStore.js
@@ -1,16 +1,18 @@
 /**
  * Tests of OSKeyStore.jsm
  */
 
 "use strict";
 
 let OSKeyStore;
 add_task(async function setup() {
+  Services.prefs.setBoolPref("extensions.formautofill.reauth.enabled", true);
+
   ({OSKeyStore} = ChromeUtils.import("resource://formautofill/OSKeyStore.jsm", {}));
 });
 
 // Ensure that the appropriate initialization has happened.
 do_get_profile();
 
 const testText = "test string";
 let cipherText;
@@ -54,16 +56,21 @@ add_task(async function test_reauth() {
   let plainText2 = await OSKeyStore.decrypt(cipherText, true);
   await reauthObserved;
   Assert.equal(testText, plainText2);
 
   reauthObserved = OSKeyStoreTestUtils.waitForOSKeyStoreLogin(true);
   await new Promise(resolve => TestUtils.executeSoon(resolve));
   Assert.equal(await OSKeyStore.ensureLoggedIn(true), true, "Reauth logged in.");
   await reauthObserved;
+
+  Services.prefs.setBoolPref("extensions.formautofill.reauth.enabled", false);
+  Assert.equal(await OSKeyStore.ensureLoggedIn(true), true,
+               "Reauth disabled so logged in without prompt");
+  Services.prefs.setBoolPref("extensions.formautofill.reauth.enabled", true);
 });
 
 add_task(async function test_decryption_failure() {
   try {
     await OSKeyStore.decrypt("Malformed cipher text");
     throw new Error("Not receiving decryption error");
   } catch (ex) {
     Assert.notEqual(ex.result, Cr.NS_ERROR_ABORT);