Bug 1378668 - [Form Autofill] Update the saved field names when a profile is updated, merged or reconciled. r=steveck
authorLuke Chang <lchang@mozilla.com>
Wed, 26 Jul 2017 19:25:36 +0800
changeset 422533 0400aea3c9ce9fde2681598ebc108d0554f33d67
parent 422532 444f087b3ffb3cfcddcebc8e9593e99f1e065e1f
child 422534 a5e025d29c794fde8d3556ecd92ba3e9a2104d4f
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssteveck
bugs1378668
milestone56.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 1378668 - [Form Autofill] Update the saved field names when a profile is updated, merged or reconciled. r=steveck MozReview-Commit-ID: 5aLqvr0n0KO
browser/extensions/formautofill/FormAutofillParent.jsm
browser/extensions/formautofill/test/unit/test_activeStatus.js
browser/extensions/formautofill/test/unit/test_savedFieldNames.js
--- a/browser/extensions/formautofill/FormAutofillParent.jsm
+++ b/browser/extensions/formautofill/FormAutofillParent.jsm
@@ -112,18 +112,18 @@ FormAutofillParent.prototype = {
 
       case "nsPref:changed": {
         // Observe pref changes and update _active cache if status is changed.
         this._updateStatus();
         break;
       }
 
       case "formautofill-storage-changed": {
-        // Early exit if the action is not "add" nor "remove"
-        if (data != "add" && data != "remove") {
+        // Early exit if only metadata is changed
+        if (data == "notifyUsed") {
           break;
         }
 
         this._updateSavedFieldNames();
         break;
       }
 
       default: {
--- a/browser/extensions/formautofill/test/unit/test_activeStatus.js
+++ b/browser/extensions/formautofill/test/unit/test_activeStatus.js
@@ -42,32 +42,28 @@ add_task(async function test_activeStatu
   do_check_eq(formAutofillParent._onStatusChanged.called, false);
 
   // _active != _computeStatus() => Need to trigger _onStatusChanged
   formAutofillParent._computeStatus.returns(false);
   formAutofillParent._onStatusChanged.reset();
   formAutofillParent.observe(null, "nsPref:changed", "extensions.formautofill.addresses.enabled");
   do_check_eq(formAutofillParent._onStatusChanged.called, true);
 
-  // profile added => Need to trigger _onStatusChanged
+  // profile changed => Need to trigger _onStatusChanged
+  ["add", "update", "remove", "reconcile", "merge"].forEach(event => {
+    formAutofillParent._computeStatus.returns(!formAutofillParent._active);
+    formAutofillParent._onStatusChanged.reset();
+    formAutofillParent.observe(null, "formautofill-storage-changed", event);
+    do_check_eq(formAutofillParent._onStatusChanged.called, true);
+  });
+
+  // profile metadata updated => No need to trigger _onStatusChanged
   formAutofillParent._computeStatus.returns(!formAutofillParent._active);
   formAutofillParent._onStatusChanged.reset();
-  formAutofillParent.observe(null, "formautofill-storage-changed", "add");
-  do_check_eq(formAutofillParent._onStatusChanged.called, true);
-
-  // profile removed => Need to trigger _onStatusChanged
-  formAutofillParent._computeStatus.returns(!formAutofillParent._active);
-  formAutofillParent._onStatusChanged.reset();
-  formAutofillParent.observe(null, "formautofill-storage-changed", "remove");
-  do_check_eq(formAutofillParent._onStatusChanged.called, true);
-
-  // profile updated => no need to trigger _onStatusChanged
-  formAutofillParent._computeStatus.returns(!formAutofillParent._active);
-  formAutofillParent._onStatusChanged.reset();
-  formAutofillParent.observe(null, "formautofill-storage-changed", "update");
+  formAutofillParent.observe(null, "formautofill-storage-changed", "notifyUsed");
   do_check_eq(formAutofillParent._onStatusChanged.called, false);
 });
 
 add_task(async function test_activeStatus_computeStatus() {
   let formAutofillParent = new FormAutofillParent();
   do_register_cleanup(function cleanup() {
     Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");
   });
--- a/browser/extensions/formautofill/test/unit/test_savedFieldNames.js
+++ b/browser/extensions/formautofill/test/unit/test_savedFieldNames.js
@@ -19,28 +19,25 @@ add_task(async function test_profileSave
 });
 
 add_task(async function test_profileSavedFieldNames_observe() {
   let formAutofillParent = new FormAutofillParent();
   sinon.stub(formAutofillParent, "_updateSavedFieldNames");
 
   await formAutofillParent.init();
 
-  // profile added => Need to trigger updateValidFields
-  formAutofillParent.observe(null, "formautofill-storage-changed", "add");
-  do_check_eq(formAutofillParent._updateSavedFieldNames.called, true);
+  // profile changed => Need to trigger updateValidFields
+  ["add", "update", "remove", "reconcile", "merge"].forEach(event => {
+    formAutofillParent.observe(null, "formautofill-storage-changed", "add");
+    do_check_eq(formAutofillParent._updateSavedFieldNames.called, true);
+  });
 
-  // profile removed => Need to trigger updateValidFields
+  // profile metadata updated => no need to trigger updateValidFields
   formAutofillParent._updateSavedFieldNames.reset();
-  formAutofillParent.observe(null, "formautofill-storage-changed", "remove");
-  do_check_eq(formAutofillParent._updateSavedFieldNames.called, true);
-
-  // profile updated => no need to trigger updateValidFields
-  formAutofillParent._updateSavedFieldNames.reset();
-  formAutofillParent.observe(null, "formautofill-storage-changed", "update");
+  formAutofillParent.observe(null, "formautofill-storage-changed", "notifyUsed");
   do_check_eq(formAutofillParent._updateSavedFieldNames.called, false);
 });
 
 add_task(async function test_profileSavedFieldNames_update() {
   let formAutofillParent = new FormAutofillParent();
   await formAutofillParent.init();
   do_register_cleanup(function cleanup() {
     Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled");