Backed out changeset 5033a269b87f (bug 1393374) for leak on OS X 10.10 debug. r=backout
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 19 Sep 2017 12:38:13 +0200
changeset 433594 9ebff732a7d1bb19852d7627de76cc2f767b7d33
parent 433593 686694b9544cae9393ff72a563a37d28741ddc0c
child 433595 2dc160bb6a349deb4af82d417e057bcf975e8054
push id1567
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 12:36:05 +0000
treeherdermozilla-release@e512c14a0406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1393374
milestone57.0a1
backs out5033a269b87f2c17a9816d2e84eafdc101e3d5af
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
Backed out changeset 5033a269b87f (bug 1393374) for leak on OS X 10.10 debug. r=backout
browser/extensions/formautofill/test/mochitest/formautofill_common.js
browser/extensions/formautofill/test/mochitest/formautofill_parent_utils.js
browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
browser/extensions/formautofill/test/mochitest/test_on_address_submission.html
--- a/browser/extensions/formautofill/test/mochitest/formautofill_common.js
+++ b/browser/extensions/formautofill/test/mochitest/formautofill_common.js
@@ -32,17 +32,17 @@ function clickOnElement(selector) {
 
   if (!element) {
     throw new Error("Can not find the element");
   }
 
   SimpleTest.executeSoon(() => element.click());
 }
 
-async function onStorageChanged(type) {
+async function onAddressChanged(type) {
   return new Promise(resolve => {
     formFillChromeScript.addMessageListener("formautofill-storage-changed", function onChanged(data) {
       formFillChromeScript.removeMessageListener("formautofill-storage-changed", onChanged);
       is(data.data, type, `Receive ${type} storage changed event`);
       resolve();
     });
   });
 }
@@ -53,68 +53,70 @@ function checkMenuEntries(expectedValues
   let expectedLength = isFormAutofillResult ? expectedValues.length + 1 : expectedValues.length;
 
   is(actualValues.length, expectedLength, " Checking length of expected menu");
   for (let i = 0; i < expectedValues.length; i++) {
     is(actualValues[i], expectedValues[i], " Checking menu entry #" + i);
   }
 }
 
-function invokeAsyncChromeTask(message, response, payload = {}) {
+async function addAddress(address) {
+  return new Promise(resolve => {
+    formFillChromeScript.sendAsyncMessage("FormAutofillTest:AddAddress", {address});
+    formFillChromeScript.addMessageListener("FormAutofillTest:AddressAdded", function onAdded(data) {
+      formFillChromeScript.removeMessageListener("FormAutofillTest:AddressAdded", onAdded);
+
+      SimpleTest.requestFlakyTimeout("Ensure ProfileAutocomplete is registered");
+      setTimeout(resolve, 500);
+    });
+  });
+}
+
+async function removeAddress(guid) {
   return new Promise(resolve => {
-    formFillChromeScript.sendAsyncMessage(message, payload);
-    formFillChromeScript.addMessageListener(response, function onReceived(data) {
-      formFillChromeScript.removeMessageListener(response, onReceived);
+    formFillChromeScript.sendAsyncMessage("FormAutofillTest:RemoveAddress", {guid});
+    formFillChromeScript.addMessageListener("FormAutofillTest:AddressRemoved", function onDeleted(data) {
+      formFillChromeScript.removeMessageListener("FormAutofillTest:AddressRemoved", onDeleted);
+
+      resolve();
+    });
+  });
+}
+
+async function updateAddress(guid, address) {
+  return new Promise(resolve => {
+    formFillChromeScript.sendAsyncMessage("FormAutofillTest:UpdateAddress", {address, guid});
+    formFillChromeScript.addMessageListener("FormAutofillTest:AddressUpdated", function onUpdated(data) {
+      formFillChromeScript.removeMessageListener("FormAutofillTest:AddressUpdated", onUpdated);
+
+      resolve();
+    });
+  });
+}
+
+async function checkAddresses(expectedAddresses) {
+  return new Promise(resolve => {
+    formFillChromeScript.sendAsyncMessage("FormAutofillTest:CheckAddresses", {expectedAddresses});
+    formFillChromeScript.addMessageListener("FormAutofillTest:areAddressesMatching", function onChecked(data) {
+      formFillChromeScript.removeMessageListener("FormAutofillTest:areAddressesMatching", onChecked);
 
       resolve(data);
     });
   });
 }
 
-async function addAddress(address) {
-  await invokeAsyncChromeTask("FormAutofillTest:AddAddress", "FormAutofillTest:AddressAdded", {address});
-  await sleep();
-}
-
-async function removeAddress(guid) {
-  return invokeAsyncChromeTask("FormAutofillTest:RemoveAddress", "FormAutofillTest:AddressRemoved", {guid});
-}
-
-async function updateAddress(guid, address) {
-  return invokeAsyncChromeTask("FormAutofillTest:UpdateAddress", "FormAutofillTest:AddressUpdated", {address, guid});
-}
-
-async function checkAddresses(expectedAddresses) {
-  return invokeAsyncChromeTask("FormAutofillTest:CheckAddresses", "FormAutofillTest:areAddressesMatching", {expectedAddresses});
-}
-
-async function cleanUpAddresses() {
-  return invokeAsyncChromeTask("FormAutofillTest:CleanUpAddresses", "FormAutofillTest:AddressesCleanedUp");
-}
+async function cleanUpAddress() {
+  return new Promise(resolve => {
+    formFillChromeScript.sendAsyncMessage("FormAutofillTest:CleanUpAddress", {});
+    formFillChromeScript.addMessageListener("FormAutofillTest:AddressCleanedUp", function onCleanedUp(data) {
+      formFillChromeScript.removeMessageListener("FormAutofillTest:AddressCleanedUp", onCleanedUp);
 
-async function addCreditCard(creditcard) {
-  await invokeAsyncChromeTask("FormAutofillTest:AddCreditCard", "FormAutofillTest:CreditCardAdded", {creditcard});
-  await sleep();
-}
-
-async function removeCreditCard(guid) {
-  return invokeAsyncChromeTask("FormAutofillTest:RemoveCreditCard", "FormAutofillTest:CreditCardRemoved", {guid});
-}
-
-async function checkCreditCards(expectedCreditCards) {
-  return invokeAsyncChromeTask("FormAutofillTest:CheckCreditCards", "FormAutofillTest:areCreditCardsMatching", {expectedCreditCards});
-}
-
-async function cleanUpCreditCards() {
-  return invokeAsyncChromeTask("FormAutofillTest:CleanUpCreditCards", "FormAutofillTest:CreditCardsCleanedUp");
-}
-
-async function cleanUpStorage() {
-  await cleanUpAddresses();
-  await cleanUpCreditCards();
+      resolve(data);
+    });
+  });
 }
 
 // Utils for registerPopupShownListener(in satchel_common.js) that handles dropdown popup
 // Please call "initPopupListener()" in your test and "await expectPopup()"
 // if you want to wait for dropdown menu displayed.
 function expectPopup() {
   info("expecting a popup");
   return new Promise(resolve => {
--- a/browser/extensions/formautofill/test/mochitest/formautofill_parent_utils.js
+++ b/browser/extensions/formautofill/test/mochitest/formautofill_parent_utils.js
@@ -2,199 +2,120 @@
 /* global assert */
 /* eslint-env mozilla/frame-script */
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://formautofill/FormAutofillUtils.jsm");
-
 let {profileStorage} = Cu.import("resource://formautofill/ProfileStorage.jsm", {});
 
-const {ADDRESSES_COLLECTION_NAME, CREDITCARDS_COLLECTION_NAME} = FormAutofillUtils;
-
 var ParentUtils = {
-  async _getRecords(collectionName) {
-    return new Promise(resolve => {
-      Services.cpmm.addMessageListener("FormAutofill:Records", function getResult({data}) {
-        Services.cpmm.removeMessageListener("FormAutofill:Records", getResult);
-        resolve(data);
-      });
-      Services.cpmm.sendAsyncMessage("FormAutofill:GetRecords", {searchString: "", collectionName});
-    });
-  },
+  cleanUpAddress() {
+    Services.cpmm.addMessageListener("FormAutofill:Records", function getResult(result) {
+      Services.cpmm.removeMessageListener("FormAutofill:Records", getResult);
+
+      let addresses = result.data;
+      Services.cpmm.sendAsyncMessage("FormAutofill:RemoveAddresses",
+                                     {guids: addresses.map(address => address.guid)});
 
-  async _storageChangeObserved({topic = "formautofill-storage-changed", type, times = 1}) {
-    let count = times;
+      let count = addresses.length;
+      Services.obs.addObserver(function observer(subject, topic, data) {
+        if (!--count) {
+          Services.obs.removeObserver(observer, topic);
+          sendAsyncMessage("FormAutofillTest:AddressCleanedUp");
+        }
+      }, "formautofill-storage-changed");
+    });
 
-    return new Promise(resolve => {
-      Services.obs.addObserver(function observer(subject, obsTopic, data) {
-        if (type && data != type || !!--count) {
-          return;
-        }
-
-        Services.obs.removeObserver(observer, obsTopic);
-        resolve();
-      }, topic);
-    });
+    Services.cpmm.sendAsyncMessage("FormAutofill:GetRecords", {searchString: "", collectionName: "addresses"});
   },
 
-  async _operateRecord(collectionName, type, msgData, contentMsg) {
-    let times, topic;
-
-    if (collectionName == ADDRESSES_COLLECTION_NAME) {
-      switch (type) {
-        case "add": {
-          Services.cpmm.sendAsyncMessage("FormAutofill:SaveAddress", msgData);
-          break;
-        }
-        case "update": {
-          Services.cpmm.sendAsyncMessage("FormAutofill:SaveAddress", msgData);
-          break;
-        }
-        case "remove": {
-          times = msgData.guids.length;
-          Services.cpmm.sendAsyncMessage("FormAutofill:RemoveAddresses", msgData);
-          break;
-        }
+  updateAddress(type, chromeMsg, msgData, contentMsg) {
+    Services.cpmm.sendAsyncMessage(chromeMsg, msgData);
+    Services.obs.addObserver(function observer(subject, topic, data) {
+      if (data != type) {
+        return;
       }
-    } else {
-      switch (type) {
-        case "add": {
-          const msgDataCloned = Object.assign({}, msgData);
 
-          Services.cpmm.sendAsyncMessage("FormAutofill:SaveCreditCard", msgDataCloned);
-          break;
-        }
-        case "remove": {
-          times = msgData.guids.length;
-          Services.cpmm.sendAsyncMessage("FormAutofill:RemoveCreditCards", msgData);
-          break;
-        }
-      }
-    }
-
-    await this._storageChangeObserved({type, times, topic});
-    sendAsyncMessage(contentMsg);
+      Services.obs.removeObserver(observer, topic);
+      sendAsyncMessage(contentMsg);
+    }, "formautofill-storage-changed");
   },
 
-  async operateAddress(type, msgData, contentMsg) {
-    await this._operateRecord(ADDRESSES_COLLECTION_NAME, ...arguments);
-  },
-
-  async operateCreditCard(type, msgData, contentMsg) {
-    await this._operateRecord(CREDITCARDS_COLLECTION_NAME, ...arguments);
-  },
-
-  async cleanUpAddresses() {
-    const guids = (await this._getRecords(ADDRESSES_COLLECTION_NAME)).map(record => record.guid);
-
-    await this.operateAddress("remove", {guids}, "FormAutofillTest:AddressesCleanedUp");
+  observe(subject, topic, data) {
+    assert.ok(topic === "formautofill-storage-changed");
+    sendAsyncMessage("formautofill-storage-changed", {subject: null, topic, data});
   },
 
-  async cleanUpCreditCards() {
-    const guids = (await this._getRecords(CREDITCARDS_COLLECTION_NAME)).map(record => record.guid);
-
-    await this.operateCreditCard("remove", {guids}, "FormAutofillTest:CreditCardsCleanedUp");
+  cleanup() {
+    Services.obs.removeObserver(this, "formautofill-storage-changed");
+    this.cleanUpAddress();
   },
 
-  async cleanup() {
-    Services.obs.removeObserver(this, "formautofill-storage-changed");
-    await this.cleanUpAddresses();
-    await this.cleanUpCreditCards();
-  },
-
-  _areRecordsMatching(recordA, recordB, collectionName) {
-    for (let field of profileStorage[collectionName].VALID_FIELDS) {
-      if (recordA[field] !== recordB[field]) {
+  areAddressesMatching(addressA, addressB) {
+    for (let field of profileStorage.addresses.VALID_FIELDS) {
+      if (addressA[field] !== addressB[field]) {
         return false;
       }
     }
     // Check the internal field if both addresses have valid value.
     for (let field of profileStorage.INTERNAL_FIELDS) {
-      if (field in recordA && field in recordB && (recordA[field] !== recordB[field])) {
+      if (field in addressA && field in addressB && (addressA[field] !== addressB[field])) {
         return false;
       }
     }
     return true;
   },
 
-  async _checkRecords(collectionName, expectedRecords) {
-    const records = await this._getRecords(collectionName);
-
-    if (records.length !== expectedRecords.length) {
-      return false;
-    }
-
-    for (let record of records) {
-      let matching = expectedRecords.some(expectedRecord => {
-        return ParentUtils._areRecordsMatching(record, expectedRecord, collectionName);
-      });
-
-      if (!matching) {
-        return false;
+  checkAddresses({expectedAddresses}) {
+    Services.cpmm.addMessageListener("FormAutofill:Records", function getResult(result) {
+      Services.cpmm.removeMessageListener("FormAutofill:Records", getResult);
+      let addresses = result.data;
+      if (addresses.length !== expectedAddresses.length) {
+        sendAsyncMessage("FormAutofillTest:areAddressesMatching", false);
+        return;
       }
-    }
 
-    return true;
-  },
-
-  async checkAddresses({expectedAddresses}) {
-    const areMatched = await this._checkRecords(ADDRESSES_COLLECTION_NAME, expectedAddresses);
-
-    sendAsyncMessage("FormAutofillTest:areAddressesMatching", areMatched);
-  },
+      for (let address of addresses) {
+        let matching = expectedAddresses.some((expectedAddress) => {
+          return ParentUtils.areAddressesMatching(address, expectedAddress);
+        });
 
-  async checkCreditCards({expectedCreditCards}) {
-    const areMatched = await this._checkRecords(CREDITCARDS_COLLECTION_NAME, expectedCreditCards);
+        if (!matching) {
+          sendAsyncMessage("FormAutofillTest:areAddressesMatching", false);
+          return;
+        }
+      }
 
-    sendAsyncMessage("FormAutofillTest:areCreditCardsMatching", areMatched);
-  },
+      sendAsyncMessage("FormAutofillTest:areAddressesMatching", true);
+    });
 
-  observe(subject, topic, data) {
-    assert.ok(topic === "formautofill-storage-changed");
-    sendAsyncMessage("formautofill-storage-changed", {subject: null, topic, data});
+    Services.cpmm.sendAsyncMessage("FormAutofill:GetRecords", {searchString: "", collectionName: "addresses"});
   },
 };
 
 Services.obs.addObserver(ParentUtils, "formautofill-storage-changed");
 
 addMessageListener("FormAutofillTest:AddAddress", (msg) => {
-  ParentUtils.operateAddress("add", msg, "FormAutofillTest:AddressAdded");
+  ParentUtils.updateAddress("add", "FormAutofill:SaveAddress", msg, "FormAutofillTest:AddressAdded");
 });
 
 addMessageListener("FormAutofillTest:RemoveAddress", (msg) => {
-  ParentUtils.operateAddress("remove", msg, "FormAutofillTest:AddressRemoved");
+  ParentUtils.updateAddress("remove", "FormAutofill:RemoveAddress", msg, "FormAutofillTest:AddressRemoved");
 });
 
 addMessageListener("FormAutofillTest:UpdateAddress", (msg) => {
-  ParentUtils.operateAddress("update", msg, "FormAutofillTest:AddressUpdated");
+  ParentUtils.updateAddress("update", "FormAutofill:SaveAddress", msg, "FormAutofillTest:AddressUpdated");
 });
 
 addMessageListener("FormAutofillTest:CheckAddresses", (msg) => {
   ParentUtils.checkAddresses(msg);
 });
 
-addMessageListener("FormAutofillTest:CleanUpAddresses", (msg) => {
-  ParentUtils.cleanUpAddresses();
-});
-
-addMessageListener("FormAutofillTest:AddCreditCard", (msg) => {
-  ParentUtils.operateCreditCard("add", msg, "FormAutofillTest:CreditCardAdded");
-});
-
-addMessageListener("FormAutofillTest:RemoveCreditCard", (msg) => {
-  ParentUtils.operateCreditCard("remove", msg, "FormAutofillTest:CreditCardRemoved");
-});
-
-addMessageListener("FormAutofillTest:CheckCreditCards", (msg) => {
-  ParentUtils.checkCreditCards(msg);
-});
-
-addMessageListener("FormAutofillTest:CleanUpCreditCards", (msg) => {
-  ParentUtils.cleanUpCreditCards();
+addMessageListener("FormAutofillTest:CleanUpAddress", (msg) => {
+  ParentUtils.cleanUpAddress();
 });
 
 addMessageListener("cleanup", () => {
   ParentUtils.cleanup();
 });
--- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
+++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html
@@ -112,17 +112,17 @@ add_task(async function all_saved_fields
     email: "test@test.com",
   });
 
   await setInput("#email", "");
   doKey("down");
   await expectPopup();
   checkMenuEntries(["foo@mozilla.com"], false);
 
-  await cleanUpAddresses();
+  await cleanUpAddress();
 });
 
 // Form with both history and address storage.
 add_task(async function check_menu_when_both_existed() {
   await setupAddressStorage();
 
   await setInput("#organization", "");
   doKey("down");
--- a/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html
+++ b/browser/extensions/formautofill/test/mochitest/test_on_address_submission.html
@@ -40,17 +40,17 @@ add_task(async function check_storage_af
 
   for (let key in TEST_ADDRESSES[0]) {
     await setInput("#" + key, TEST_ADDRESSES[0][key]);
   }
 
   clickOnElement("input[type=submit]");
 
   let expectedAddresses = TEST_ADDRESSES.slice(0, 1);
-  await onStorageChanged("add");
+  await onAddressChanged("add");
   // Check if timesUsed is set correctly
   expectedAddresses[0].timesUsed = 1;
   let matching = await checkAddresses(expectedAddresses);
   ok(matching, "Address saved as expected");
   delete expectedAddresses[0].timesUsed;
 });
 
 // Submit another new address.
@@ -62,17 +62,17 @@ add_task(async function check_storage_af
 
   clickOnElement("input[type=submit]");
 
   // The 2nd test address should be on the top since it's the last used one.
   let addressesInMenu = TEST_ADDRESSES.slice(1);
   addressesInMenu.push(TEST_ADDRESSES[0]);
 
   // let expectedAddresses = TEST_ADDRESSES.slice(0);
-  await onStorageChanged("add");
+  await onAddressChanged("add");
   let matching = await checkAddresses(TEST_ADDRESSES);
   ok(matching, "New address saved as expected");
 
   await setInput("#organization", "");
   doKey("down");
   await expectPopup();
   checkMenuEntries(addressesInMenu.map(address =>
     JSON.stringify({primary: address.organization, secondary: address["street-address"]})
@@ -88,17 +88,17 @@ add_task(async function new_address_subm
   // Add country to first address in storage
   await setInput("#country", "US");
   TEST_ADDRESSES[0].country = "US";
   clickOnElement("input[type=submit]");
 
   let expectedAddresses = TEST_ADDRESSES.slice(0);
   // Check if timesUsed is set correctly
   expectedAddresses[0].timesUsed = 2;
-  await onStorageChanged("merge");
+  await onAddressChanged("merge");
   let matching = await checkAddresses(expectedAddresses);
   ok(matching, "Address merged as expected");
   delete expectedAddresses[0].timesUsed;
 });
 
 // Submit an updated autofill address and merge.
 add_task(async function check_storage_after_form_submitted() {
   document.querySelector("form").reset();
@@ -109,17 +109,17 @@ add_task(async function check_storage_af
   await setInput("#organization", "Moz");
   doKey("down");
   await expectPopup();
   doKey("down");
   doKey("return");
   clickOnElement("input[type=submit]");
 
   let expectedAddresses = TEST_ADDRESSES.slice(0);
-  await onStorageChanged("merge");
+  await onAddressChanged("merge");
   let matching = await checkAddresses(expectedAddresses);
   ok(matching, "Updated address merged as expected");
 });
 
 </script>
 
 <div>