author | Daniel Marshall <daniel@starsandspirals.com> |
Sat, 10 Feb 2018 21:23:19 +0000 | |
changeset 461786 | ca36a410083e0d3e83da58ef4cace584c5bd65ae |
parent 461785 | a7029424d92a7f65fade0c014136fe5bca3ce8f8 |
child 461801 | c2469b3f1a0441cdaa032633fc61c311ceaabbd8 |
push id | 1683 |
push user | sfraser@mozilla.com |
push date | Thu, 26 Apr 2018 16:43:40 +0000 |
treeherder | mozilla-release@5af6cb21869d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | MattN |
bugs | 1434483 |
milestone | 60.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
|
--- a/browser/components/migration/tests/marionette/test_refresh_firefox.py +++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py @@ -120,18 +120,18 @@ class TestFirefoxRefresh(MarionetteTestC "street-address": "32 Vassar Street\\\nMIT Room 32-G524", "address-level2": "Cambridge", "address-level1": "MA", "postal-code": "02139", country: "US", tel: "+15195555555", email: "user@example.com", }; - return global.profileStorage.initialize().then(() => { - return global.profileStorage.addresses.add(TEST_ADDRESS_1); + return global.formAutofillStorage.initialize().then(() => { + return global.formAutofillStorage.addresses.add(TEST_ADDRESS_1); }).then(marionetteScriptFinished); """) def createCookie(self): self.runCode(""" // Expire in 15 minutes: let expireTime = Math.floor(Date.now() / 1000) + 15 * 60; Services.cookies.add(arguments[0], arguments[1], arguments[2], arguments[3], @@ -276,18 +276,18 @@ class TestFirefoxRefresh(MarionetteTestC """) self.assertEqual(formHistoryCount, 1, "There should be only 1 entry in the form history") def checkFormAutofill(self): if not self._formAutofillAvailable: return formAutofillResults = self.runAsyncCode(""" - return global.profileStorage.initialize().then(() => { - return global.profileStorage.addresses.getAll() + return global.formAutofillStorage.initialize().then(() => { + return global.formAutofillStorage.addresses.getAll() }).then(marionetteScriptFinished); """,) if type(formAutofillResults) == str: self.fail(formAutofillResults) return formAutofillAddressCount = len(formAutofillResults) self.assertEqual(formAutofillAddressCount, 1, "Should have exactly 1 saved address, got %d" % formAutofillAddressCount) @@ -419,17 +419,17 @@ class TestFirefoxRefresh(MarionetteTestC window.global = {}; global.LoginInfo = Components.Constructor("@mozilla.org/login-manager/loginInfo;1", "nsILoginInfo", "init"); global.profSvc = Cc["@mozilla.org/toolkit/profile-service;1"].getService(Ci.nsIToolkitProfileService); global.Preferences = Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences; global.FormHistory = Cu.import("resource://gre/modules/FormHistory.jsm", {}).FormHistory; """) self._formAutofillAvailable = self.runCode(""" try { - global.profileStorage = Cu.import("resource://formautofill/FormAutofillStorage.jsm", {}).profileStorage; + global.formAutofillStorage = Cu.import("resource://formautofill/FormAutofillStorage.jsm", {}).formAutofillStorage; } catch(e) { return false; } return true; """) def runCode(self, script, *args, **kwargs): return self.marionette.execute_script(script,
--- a/browser/extensions/formautofill/FormAutofillParent.jsm +++ b/browser/extensions/formautofill/FormAutofillParent.jsm @@ -52,26 +52,26 @@ const { ENABLED_AUTOFILL_ADDRESSES_PREF, ENABLED_AUTOFILL_CREDITCARDS_PREF, CREDITCARDS_COLLECTION_NAME, } = FormAutofillUtils; function FormAutofillParent() { // Lazily load the storage JSM to avoid disk I/O until absolutely needed. // Once storage is loaded we need to update saved field names and inform content processes. - XPCOMUtils.defineLazyGetter(this, "profileStorage", () => { - let {profileStorage} = ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm", {}); - log.debug("Loading profileStorage"); + XPCOMUtils.defineLazyGetter(this, "formAutofillStorage", () => { + let {formAutofillStorage} = ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm", {}); + log.debug("Loading formAutofillStorage"); - profileStorage.initialize().then(() => { + formAutofillStorage.initialize().then(() => { // Update the saved field names to compute the status and update child processes. this._updateSavedFieldNames(); }); - return profileStorage; + return formAutofillStorage; }); } FormAutofillParent.prototype = { QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports, Ci.nsIObserver]), /** * Cache of the Form Autofill status (considering preferences and storage). @@ -200,47 +200,47 @@ FormAutofillParent.prototype = { * * @param {string} message.name The name of the message. * @param {object} message.data The data of the message. * @param {nsIFrameMessageManager} message.target Caller's message manager. */ async receiveMessage({name, data, target}) { switch (name) { case "FormAutofill:InitStorage": { - this.profileStorage.initialize(); + this.formAutofillStorage.initialize(); break; } case "FormAutofill:GetRecords": { this._getRecords(data, target); break; } case "FormAutofill:SaveAddress": { if (data.guid) { - this.profileStorage.addresses.update(data.guid, data.address); + this.formAutofillStorage.addresses.update(data.guid, data.address); } else { - this.profileStorage.addresses.add(data.address); + this.formAutofillStorage.addresses.add(data.address); } break; } case "FormAutofill:SaveCreditCard": { // TODO: "MasterPassword.ensureLoggedIn" can be removed after the storage // APIs are refactored to be async functions (bug 1399367). if (!await MasterPassword.ensureLoggedIn()) { log.warn("User canceled master password entry"); return; } - this.profileStorage.creditCards.add(data.creditcard); + this.formAutofillStorage.creditCards.add(data.creditcard); break; } case "FormAutofill:RemoveAddresses": { - data.guids.forEach(guid => this.profileStorage.addresses.remove(guid)); + data.guids.forEach(guid => this.formAutofillStorage.addresses.remove(guid)); break; } case "FormAutofill:RemoveCreditCards": { - data.guids.forEach(guid => this.profileStorage.creditCards.remove(guid)); + data.guids.forEach(guid => this.formAutofillStorage.creditCards.remove(guid)); break; } case "FormAutofill:OnFormSubmit": { this._onFormSubmit(data, target); break; } case "FormAutofill:OpenPreferences": { const win = RecentWindow.getMostRecentBrowserWindow(); @@ -265,17 +265,17 @@ FormAutofillParent.prototype = { }, /** * Uninitializes FormAutofillParent. This is for testing only. * * @private */ _uninit() { - this.profileStorage._saveImmediately(); + this.formAutofillStorage._saveImmediately(); Services.ppmm.removeMessageListener("FormAutofill:InitStorage", this); Services.ppmm.removeMessageListener("FormAutofill:GetRecords", this); Services.ppmm.removeMessageListener("FormAutofill:SaveAddress", this); Services.ppmm.removeMessageListener("FormAutofill:RemoveAddresses", this); Services.obs.removeObserver(this, "sync-pane-loaded"); Services.prefs.removeObserver(ENABLED_AUTOFILL_ADDRESSES_PREF, this); @@ -298,17 +298,17 @@ FormAutofillParent.prototype = { * @param {string} data.searchString * The typed string for filtering out the matched records. * @param {string} data.info * The input autocomplete property's information. * @param {nsIFrameMessageManager} target * Content's message manager. */ async _getRecords({collectionName, searchString, info}, target) { - let collection = this.profileStorage[collectionName]; + let collection = this.formAutofillStorage[collectionName]; if (!collection) { target.sendAsyncMessage("FormAutofill:Records", []); return; } let recordsInCollection = collection.getAll(); if (!info || !info.fieldName || !recordsInCollection.length) { target.sendAsyncMessage("FormAutofill:Records", recordsInCollection); @@ -355,85 +355,85 @@ FormAutofillParent.prototype = { log.debug("_updateSavedFieldNames"); if (!Services.ppmm.initialProcessData.autofillSavedFieldNames) { Services.ppmm.initialProcessData.autofillSavedFieldNames = new Set(); } else { Services.ppmm.initialProcessData.autofillSavedFieldNames.clear(); } ["addresses", "creditCards"].forEach(c => { - this.profileStorage[c].getAll().forEach((record) => { + this.formAutofillStorage[c].getAll().forEach((record) => { Object.keys(record).forEach((fieldName) => { if (!record[fieldName]) { return; } Services.ppmm.initialProcessData.autofillSavedFieldNames.add(fieldName); }); }); }); // Remove the internal guid and metadata fields. - this.profileStorage.INTERNAL_FIELDS.forEach((fieldName) => { + this.formAutofillStorage.INTERNAL_FIELDS.forEach((fieldName) => { Services.ppmm.initialProcessData.autofillSavedFieldNames.delete(fieldName); }); Services.ppmm.broadcastAsyncMessage("FormAutofill:savedFieldNames", Services.ppmm.initialProcessData.autofillSavedFieldNames); this._updateStatus(); }, _onAddressSubmit(address, target, timeStartedFillingMS) { let showDoorhanger = null; if (address.guid) { // Avoid updating the fields that users don't modify. - let originalAddress = this.profileStorage.addresses.get(address.guid); + let originalAddress = this.formAutofillStorage.addresses.get(address.guid); for (let field in address.record) { if (address.untouchedFields.includes(field) && originalAddress[field]) { address.record[field] = originalAddress[field]; } } - if (!this.profileStorage.addresses.mergeIfPossible(address.guid, address.record, true)) { + if (!this.formAutofillStorage.addresses.mergeIfPossible(address.guid, address.record, true)) { this._recordFormFillingTime("address", "autofill-update", timeStartedFillingMS); showDoorhanger = async () => { const description = FormAutofillUtils.getAddressLabel(address.record); const state = await FormAutofillDoorhanger.show(target, "updateAddress", description); - let changedGUIDs = this.profileStorage.addresses.mergeToStorage(address.record, true); + let changedGUIDs = this.formAutofillStorage.addresses.mergeToStorage(address.record, true); switch (state) { case "create": if (!changedGUIDs.length) { - changedGUIDs.push(this.profileStorage.addresses.add(address.record)); + changedGUIDs.push(this.formAutofillStorage.addresses.add(address.record)); } break; case "update": if (!changedGUIDs.length) { - this.profileStorage.addresses.update(address.guid, address.record, true); + this.formAutofillStorage.addresses.update(address.guid, address.record, true); changedGUIDs.push(address.guid); } else { - this.profileStorage.addresses.remove(address.guid); + this.formAutofillStorage.addresses.remove(address.guid); } break; } - changedGUIDs.forEach(guid => this.profileStorage.addresses.notifyUsed(guid)); + changedGUIDs.forEach(guid => this.formAutofillStorage.addresses.notifyUsed(guid)); }; // Address should be updated Services.telemetry.scalarAdd("formautofill.addresses.fill_type_autofill_update", 1); } else { this._recordFormFillingTime("address", "autofill", timeStartedFillingMS); - this.profileStorage.addresses.notifyUsed(address.guid); + this.formAutofillStorage.addresses.notifyUsed(address.guid); // Address is merged successfully Services.telemetry.scalarAdd("formautofill.addresses.fill_type_autofill", 1); } } else { - let changedGUIDs = this.profileStorage.addresses.mergeToStorage(address.record); + let changedGUIDs = this.formAutofillStorage.addresses.mergeToStorage(address.record); if (!changedGUIDs.length) { - changedGUIDs.push(this.profileStorage.addresses.add(address.record)); + changedGUIDs.push(this.formAutofillStorage.addresses.add(address.record)); } - changedGUIDs.forEach(guid => this.profileStorage.addresses.notifyUsed(guid)); + changedGUIDs.forEach(guid => this.formAutofillStorage.addresses.notifyUsed(guid)); this._recordFormFillingTime("address", "manual", timeStartedFillingMS); // Show first time use doorhanger if (FormAutofillUtils.isAutofillAddressesFirstTimeUse) { Services.prefs.setBoolPref(FormAutofillUtils.ADDRESSES_FIRST_TIME_USE_PREF, false); showDoorhanger = async () => { const description = FormAutofillUtils.getAddressLabel(address.record); const state = await FormAutofillDoorhanger.show(target, "firstTimeUse", description); @@ -463,34 +463,34 @@ FormAutofillParent.prototype = { // We'll show the credit card doorhanger if: // - User applys autofill and changed // - User fills form manually and the filling data is not duplicated to storage if (creditCard.guid) { // Indicate that the user has used Credit Card Autofill to fill in a form. setUsedStatus(3); - let originalCCData = this.profileStorage.creditCards.get(creditCard.guid); + let originalCCData = this.formAutofillStorage.creditCards.get(creditCard.guid); let recordUnchanged = true; for (let field in creditCard.record) { if (creditCard.record[field] === "" && !originalCCData[field]) { continue; } // Avoid updating the fields that users don't modify, but skip number field // because we don't want to trigger decryption here. let untouched = creditCard.untouchedFields.includes(field); if (untouched && field !== "cc-number") { creditCard.record[field] = originalCCData[field]; } // recordUnchanged will be false if one of the field is changed. recordUnchanged &= untouched; } if (recordUnchanged) { - this.profileStorage.creditCards.notifyUsed(creditCard.guid); + this.formAutofillStorage.creditCards.notifyUsed(creditCard.guid); // Add probe to record credit card autofill(without modification). Services.telemetry.scalarAdd("formautofill.creditCards.fill_type_autofill", 1); this._recordFormFillingTime("creditCard", "autofill", timeStartedFillingMS); return false; } // Add the probe to record credit card autofill with modification. Services.telemetry.scalarAdd("formautofill.creditCards.fill_type_autofill_modified", 1); this._recordFormFillingTime("creditCard", "autofill-update", timeStartedFillingMS); @@ -501,19 +501,19 @@ FormAutofillParent.prototype = { setUsedStatus(1); // Add the probe to record credit card manual filling. Services.telemetry.scalarAdd("formautofill.creditCards.fill_type_manual", 1); this._recordFormFillingTime("creditCard", "manual", timeStartedFillingMS); } // Early return if it's a duplicate data - let dupGuid = this.profileStorage.creditCards.getDuplicateGuid(creditCard.record); + let dupGuid = this.formAutofillStorage.creditCards.getDuplicateGuid(creditCard.record); if (dupGuid) { - this.profileStorage.creditCards.notifyUsed(dupGuid); + this.formAutofillStorage.creditCards.notifyUsed(dupGuid); return false; } // Indicate that the user has seen the doorhanger. setUsedStatus(2); return async () => { // Suppress the pending doorhanger from showing up if user disabled credit card in previous doorhanger. @@ -539,28 +539,28 @@ FormAutofillParent.prototype = { if (!await MasterPassword.ensureLoggedIn()) { log.warn("User canceled master password entry"); return; } let changedGUIDs = []; if (creditCard.guid) { if (state == "update") { - this.profileStorage.creditCards.update(creditCard.guid, creditCard.record, true); + this.formAutofillStorage.creditCards.update(creditCard.guid, creditCard.record, true); changedGUIDs.push(creditCard.guid); } else if ("create") { - changedGUIDs.push(this.profileStorage.creditCards.add(creditCard.record)); + changedGUIDs.push(this.formAutofillStorage.creditCards.add(creditCard.record)); } } else { - changedGUIDs.push(...this.profileStorage.creditCards.mergeToStorage(creditCard.record)); + changedGUIDs.push(...this.formAutofillStorage.creditCards.mergeToStorage(creditCard.record)); if (!changedGUIDs.length) { - changedGUIDs.push(this.profileStorage.creditCards.add(creditCard.record)); + changedGUIDs.push(this.formAutofillStorage.creditCards.add(creditCard.record)); } } - changedGUIDs.forEach(guid => this.profileStorage.creditCards.notifyUsed(guid)); + changedGUIDs.forEach(guid => this.formAutofillStorage.creditCards.notifyUsed(guid)); }; }, async _onFormSubmit(data, target) { let {profile: {address, creditCard}, timeStartedFillingMS} = data; // Don't record filling time if any type of records has more than one section being // populated. We've been recording the filling time, so the other cases that aren't
--- a/browser/extensions/formautofill/FormAutofillStorage.jsm +++ b/browser/extensions/formautofill/FormAutofillStorage.jsm @@ -116,17 +116,17 @@ * (meaning they will be synced on the next sync), at which time they will gain * this new field. */ "use strict"; // We expose a singleton from this module. Some tests may import the // constructor via a backstage pass. -var EXPORTED_SYMBOLS = ["profileStorage"]; +this.EXPORTED_SYMBOLS = ["formAutofillStorage"]; ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/osfile.jsm"); ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm"); ChromeUtils.defineModuleGetter(this, "JSONFile", @@ -1797,10 +1797,10 @@ FormAutofillStorage.prototype = { // For test only. _saveImmediately() { return this._store._save(); }, }; // The singleton exposed by this module. -var profileStorage = new FormAutofillStorage( +this.formAutofillStorage = new FormAutofillStorage( OS.Path.join(OS.Constants.Path.profileDir, PROFILE_JSON_FILE_NAME));
--- a/browser/extensions/formautofill/FormAutofillSync.jsm +++ b/browser/extensions/formautofill/FormAutofillSync.jsm @@ -11,17 +11,17 @@ ChromeUtils.import("resource://gre/modul ChromeUtils.import("resource://services-sync/engines.js"); ChromeUtils.import("resource://services-sync/record.js"); ChromeUtils.import("resource://services-sync/util.js"); ChromeUtils.import("resource://services-sync/constants.js"); ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm"); ChromeUtils.defineModuleGetter(this, "Log", "resource://gre/modules/Log.jsm"); -ChromeUtils.defineModuleGetter(this, "profileStorage", +ChromeUtils.defineModuleGetter(this, "formAutofillStorage", "resource://formautofill/FormAutofillStorage.jsm"); // A helper to sanitize address and creditcard records suitable for logging. function sanitizeStorageObject(ob) { if (!ob) { return null; } const whitelist = ["timeCreated", "timeLastUsed", "timeLastModified"]; @@ -52,17 +52,17 @@ AutofillRecord.prototype = { guid: this.id, }, this.entry); }, fromEntry(entry) { this.id = entry.guid; this.entry = entry; // The GUID is already stored in record.id, so we nuke it from the entry - // itself to save a tiny bit of space. The profileStorage clones profiles, + // itself to save a tiny bit of space. The formAutofillStorage clones profiles, // so nuking in-place is OK. delete this.entry.guid; }, cleartextToString() { // And a helper so logging a *Sync* record auto sanitizes. let record = this.cleartext; return JSON.stringify({entry: sanitizeStorageObject(record.entry)}); @@ -79,17 +79,17 @@ function FormAutofillStore(name, engine) FormAutofillStore.prototype = { __proto__: Store.prototype, _subStorageName: null, // overridden below. _storage: null, get storage() { if (!this._storage) { - this._storage = profileStorage[this._subStorageName]; + this._storage = formAutofillStorage[this._subStorageName]; } return this._storage; }, async getAllIDs() { let result = {}; for (let {guid} of this.storage.getAll({includeDeleted: true})) { result[guid] = true; @@ -97,17 +97,17 @@ FormAutofillStore.prototype = { return result; }, async changeItemID(oldID, newID) { this.storage.changeGUID(oldID, newID); }, // Note: this function intentionally returns false in cases where we only have - // a (local) tombstone - and profileStorage.get() filters them for us. + // a (local) tombstone - and formAutofillStorage.get() filters them for us. async itemExists(id) { return Boolean(this.storage.get(id)); }, async applyIncoming(remoteRecord) { if (remoteRecord.deleted) { this._log.trace("Deleting record", remoteRecord); this.storage.remove(remoteRecord.id, {sourceSync: true}); @@ -286,17 +286,17 @@ FormAutofillEngine.prototype = { // the priority for this engine is == addons, so will happen after bookmarks // prefs and tabs, but before forms, history, etc. syncPriority: 5, // We don't use SyncEngine.initialize() for this, as we initialize even if // the engine is disabled, and we don't want to be the loader of // FormAutofillStorage in this case. async _syncStartup() { - await profileStorage.initialize(); + await formAutofillStorage.initialize(); await SyncEngine.prototype._syncStartup.call(this); }, // We handle reconciliation in the store, not the engine. async _reconcile() { return true; }, @@ -324,17 +324,17 @@ FormAutofillEngine.prototype = { this._store.storage.pushSyncChanges(this._modified.changes); }, _deleteId(id) { this._noteDeletedId(id); }, async _resetClient() { - await profileStorage.initialize(); + await formAutofillStorage.initialize(); this._store.storage.resetSync(); }, }; // The concrete engines function AddressesRecord(collection, id) { AutofillRecord.call(this, collection, id);
--- a/browser/extensions/formautofill/content/editDialog.js +++ b/browser/extensions/formautofill/content/editDialog.js @@ -8,24 +8,24 @@ const AUTOFILL_BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties"; const REGIONS_BUNDLE_URI = "chrome://global/locale/regionNames.properties"; ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm"); -ChromeUtils.defineModuleGetter(this, "profileStorage", +ChromeUtils.defineModuleGetter(this, "formAutofillStorage", "resource://formautofill/FormAutofillStorage.jsm"); ChromeUtils.defineModuleGetter(this, "MasterPassword", "resource://formautofill/MasterPassword.jsm"); class EditDialog { constructor(subStorageName, elements, record) { - this._storageInitPromise = profileStorage.initialize(); + this._storageInitPromise = formAutofillStorage.initialize(); this._subStorageName = subStorageName; this._elements = elements; this._record = record; this.localizeDocument(); window.addEventListener("DOMContentLoaded", this, {once: true}); } async init() { @@ -70,17 +70,17 @@ class EditDialog { } /** * Get storage and ensure it has been initialized. * @returns {object} */ async getStorage() { await this._storageInitPromise; - return profileStorage[this._subStorageName]; + return formAutofillStorage[this._subStorageName]; } /** * Asks FormAutofillParent to save or update an record. * @param {object} record * @param {string} guid [optional] */ async saveRecord(record, guid) {
--- a/browser/extensions/formautofill/content/manageDialog.js +++ b/browser/extensions/formautofill/content/manageDialog.js @@ -9,27 +9,27 @@ const EDIT_ADDRESS_URL = "chrome://formautofill/content/editAddress.xhtml"; const EDIT_CREDIT_CARD_URL = "chrome://formautofill/content/editCreditCard.xhtml"; const AUTOFILL_BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties"; ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm"); -ChromeUtils.defineModuleGetter(this, "profileStorage", +ChromeUtils.defineModuleGetter(this, "formAutofillStorage", "resource://formautofill/FormAutofillStorage.jsm"); ChromeUtils.defineModuleGetter(this, "MasterPassword", "resource://formautofill/MasterPassword.jsm"); this.log = null; FormAutofillUtils.defineLazyLogGetter(this, "manageAddresses"); class ManageRecords { constructor(subStorageName, elements) { - this._storageInitPromise = profileStorage.initialize(); + this._storageInitPromise = formAutofillStorage.initialize(); this._subStorageName = subStorageName; this._elements = elements; this._newRequest = false; this._isLoadingRecords = false; this.prefWin = window.opener; this.localizeDocument(); window.addEventListener("DOMContentLoaded", this, {once: true}); } @@ -62,17 +62,17 @@ class ManageRecords { } /** * Get storage and ensure it has been initialized. * @returns {object} */ async getStorage() { await this._storageInitPromise; - return profileStorage[this._subStorageName]; + return formAutofillStorage[this._subStorageName]; } /** * Load records and render them. This function is a wrapper for _loadRecords * to ensure any reentrant will be handled well. */ async loadRecords() { // This function can be early returned when there is any reentrant happends.
--- a/browser/extensions/formautofill/test/mochitest/formautofill_parent_utils.js +++ b/browser/extensions/formautofill/test/mochitest/formautofill_parent_utils.js @@ -2,17 +2,17 @@ /* global assert */ /* eslint-env mozilla/frame-script */ "use strict"; ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://formautofill/FormAutofillUtils.jsm"); -let {profileStorage} = ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm", {}); +let {formAutofillStorage} = ChromeUtils.import("resource://formautofill/FormAutofillStorage.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); @@ -108,23 +108,23 @@ var ParentUtils = { async cleanup() { await this.cleanUpAddresses(); await this.cleanUpCreditCards(); Services.obs.removeObserver(this, "formautofill-storage-changed"); }, _areRecordsMatching(recordA, recordB, collectionName) { - for (let field of profileStorage[collectionName].VALID_FIELDS) { + for (let field of formAutofillStorage[collectionName].VALID_FIELDS) { if (recordA[field] !== recordB[field]) { return false; } } // Check the internal field if both addresses have valid value. - for (let field of profileStorage.INTERNAL_FIELDS) { + for (let field of formAutofillStorage.INTERNAL_FIELDS) { if (field in recordA && field in recordB && (recordA[field] !== recordB[field])) { return false; } } return true; }, async _checkRecords(collectionName, expectedRecords) {
--- a/browser/extensions/formautofill/test/unit/test_activeStatus.js +++ b/browser/extensions/formautofill/test/unit/test_activeStatus.js @@ -17,17 +17,17 @@ add_task(async function test_activeStatu await formAutofillParent.init(); // init shouldn't call updateStatus since that requires storage which will // lead to startup time regressions. Assert.equal(formAutofillParent._updateStatus.called, false); Assert.equal(Services.ppmm.initialProcessData.autofillEnabled, undefined); // Initialize profile storage - await formAutofillParent.profileStorage.initialize(); + await formAutofillParent.formAutofillStorage.initialize(); // Upon first initializing profile storage, status should be computed. Assert.equal(formAutofillParent._updateStatus.called, true); Assert.equal(Services.ppmm.initialProcessData.autofillEnabled, false); formAutofillParent._uninit(); }); add_task(async function test_activeStatus_observe() { @@ -66,30 +66,30 @@ add_task(async function test_activeStatu add_task(async function test_activeStatus_computeStatus() { let formAutofillParent = new FormAutofillParent(); registerCleanupFunction(function cleanup() { Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled"); Services.prefs.clearUserPref("extensions.formautofill.creditCards.enabled"); }); - sinon.stub(profileStorage.addresses, "getAll"); - profileStorage.addresses.getAll.returns([]); + sinon.stub(formAutofillParent.formAutofillStorage.addresses, "getAll"); + formAutofillParent.formAutofillStorage.addresses.getAll.returns([]); // pref is enabled and profile is empty. Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", true); Services.prefs.setBoolPref("extensions.formautofill.creditCards.enabled", true); Assert.equal(formAutofillParent._computeStatus(), false); // pref is disabled and profile is empty. Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", false); Services.prefs.setBoolPref("extensions.formautofill.creditCards.enabled", false); Assert.equal(formAutofillParent._computeStatus(), false); - profileStorage.addresses.getAll.returns([{"given-name": "John"}]); + formAutofillParent.formAutofillStorage.addresses.getAll.returns([{"given-name": "John"}]); formAutofillParent.observe(null, "formautofill-storage-changed", "add"); // pref is enabled and profile is not empty. Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", true); Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", true); Assert.equal(formAutofillParent._computeStatus(), true); // pref is partial enabled and profile is not empty. Services.prefs.setBoolPref("extensions.formautofill.addresses.enabled", true);
--- a/browser/extensions/formautofill/test/unit/test_getRecords.js +++ b/browser/extensions/formautofill/test/unit/test_getRecords.js @@ -44,34 +44,34 @@ let TEST_CREDIT_CARD_2 = { let target = { sendAsyncMessage: function sendAsyncMessage(msg, payload) {}, }; add_task(async function test_getRecords() { let formAutofillParent = new FormAutofillParent(); await formAutofillParent.init(); - await formAutofillParent.profileStorage.initialize(); + await formAutofillParent.formAutofillStorage.initialize(); let fakeResult = { addresses: [{ "given-name": "Timothy", "additional-name": "John", "family-name": "Berners-Lee", "organization": "World Wide Web Consortium", }], creditCards: [{ "cc-name": "John Doe", "cc-number": "1234567812345678", "cc-exp-month": 4, "cc-exp-year": 2017, }], }; for (let collectionName of ["addresses", "creditCards", "nonExisting"]) { - let collection = profileStorage[collectionName]; + let collection = formAutofillParent.formAutofillStorage[collectionName]; let expectedResult = fakeResult[collectionName] || []; let mock = sinon.mock(target); mock.expects("sendAsyncMessage").once().withExactArgs("FormAutofill:Records", expectedResult); if (collection) { sinon.stub(collection, "getAll"); collection.getAll.returns(expectedResult); } @@ -83,19 +83,19 @@ add_task(async function test_getRecords( } } }); add_task(async function test_getRecords_addresses() { let formAutofillParent = new FormAutofillParent(); await formAutofillParent.init(); - await formAutofillParent.profileStorage.initialize(); + await formAutofillParent.formAutofillStorage.initialize(); let mockAddresses = [TEST_ADDRESS_1, TEST_ADDRESS_2]; - let collection = profileStorage.addresses; + let collection = formAutofillParent.formAutofillStorage.addresses; sinon.stub(collection, "getAll"); collection.getAll.returns(mockAddresses); let testCases = [ { description: "If the search string could match 1 address", filter: { collectionName: "addresses", @@ -160,18 +160,18 @@ add_task(async function test_getRecords_ mock.verify(); } }); add_task(async function test_getRecords_creditCards() { let formAutofillParent = new FormAutofillParent(); await formAutofillParent.init(); - await formAutofillParent.profileStorage.initialize(); - let collection = profileStorage.creditCards; + await formAutofillParent.formAutofillStorage.initialize(); + let collection = formAutofillParent.formAutofillStorage.creditCards; let encryptedCCRecords = [TEST_CREDIT_CARD_1, TEST_CREDIT_CARD_2].map(record => { let clonedRecord = Object.assign({}, record); clonedRecord["cc-number"] = collection._getMaskedCCNumber(record["cc-number"]); clonedRecord["cc-number-encrypted"] = MasterPassword.encryptSync(record["cc-number"]); return clonedRecord; }); sinon.stub(collection, "getAll", () => [Object.assign({}, encryptedCCRecords[0]), Object.assign({}, encryptedCCRecords[1])]); let CreditCardsWithDecryptedNumber = [
--- a/browser/extensions/formautofill/test/unit/test_savedFieldNames.js +++ b/browser/extensions/formautofill/test/unit/test_savedFieldNames.js @@ -7,17 +7,17 @@ let {FormAutofillParent} = ChromeUtils.import("resource://formautofill/FormAutofillParent.jsm", {}); ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm"); add_task(async function test_profileSavedFieldNames_init() { let formAutofillParent = new FormAutofillParent(); sinon.stub(formAutofillParent, "_updateSavedFieldNames"); await formAutofillParent.init(); - await formAutofillParent.profileStorage.initialize(); + await formAutofillParent.formAutofillStorage.initialize(); Assert.equal(formAutofillParent._updateSavedFieldNames.called, true); formAutofillParent._uninit(); }); add_task(async function test_profileSavedFieldNames_observe() { let formAutofillParent = new FormAutofillParent(); sinon.stub(formAutofillParent, "_updateSavedFieldNames"); @@ -38,18 +38,18 @@ add_task(async function test_profileSave add_task(async function test_profileSavedFieldNames_update() { let formAutofillParent = new FormAutofillParent(); await formAutofillParent.init(); registerCleanupFunction(function cleanup() { Services.prefs.clearUserPref("extensions.formautofill.addresses.enabled"); }); - sinon.stub(profileStorage.addresses, "getAll"); - profileStorage.addresses.getAll.returns([]); + sinon.stub(formAutofillParent.formAutofillStorage.addresses, "getAll"); + formAutofillParent.formAutofillStorage.addresses.getAll.returns([]); // The set is empty if there's no profile in the store. formAutofillParent._updateSavedFieldNames(); Assert.equal(Services.ppmm.initialProcessData.autofillSavedFieldNames.size, 0); // 2 profiles with 4 valid fields. let fakeStorage = [{ guid: "test-guid-1", @@ -67,17 +67,17 @@ add_task(async function test_profileSave "street-address": "331 E. Evelyn Avenue", tel: "1-650-903-0800", country: "US", timeCreated: 0, timeLastUsed: 0, timeLastModified: 0, timesUsed: 0, }]; - profileStorage.addresses.getAll.returns(fakeStorage); + formAutofillParent.formAutofillStorage.addresses.getAll.returns(fakeStorage); formAutofillParent._updateSavedFieldNames(); let autofillSavedFieldNames = Services.ppmm.initialProcessData.autofillSavedFieldNames; Assert.equal(autofillSavedFieldNames.size, 4); Assert.equal(autofillSavedFieldNames.has("organization"), true); Assert.equal(autofillSavedFieldNames.has("street-address"), true); Assert.equal(autofillSavedFieldNames.has("tel"), true); Assert.equal(autofillSavedFieldNames.has("email"), false);
--- a/services/sync/tps/extensions/tps/resource/modules/formautofill.jsm +++ b/services/sync/tps/extensions/tps/resource/modules/formautofill.jsm @@ -24,17 +24,17 @@ class FormAutofillBase { this.updateProps = props.changes; } for (const field of this._fields) { this.props[field] = (field in props) ? props[field] : null; } } get storage() { - return profileStorage[this._subStorageName]; + return formAutofillStorage[this._subStorageName]; } Create() { this.storage.add(this.props); } Find() { return this.storage._data.find(entry => @@ -50,17 +50,17 @@ class FormAutofillBase { Remove() { const {guid} = this.Find(); this.storage.remove(guid); } } function DumpStorage(subStorageName) { Logger.logInfo(`\ndumping ${subStorageName} list\n`, true); - const entries = profileStorage[subStorageName]._data; + const entries = formAutofillStorage[subStorageName]._data; for (const entry of entries) { Logger.logInfo(JSON.stringify(entry), true); } Logger.logInfo(`\n\nend ${subStorageName} list\n`, true); } const ADDRESS_FIELDS = [ "given-name",
--- a/toolkit/components/payments/content/paymentDialogWrapper.js +++ b/toolkit/components/payments/content/paymentDialogWrapper.js @@ -13,49 +13,49 @@ const paymentSrv = Cc["@mozilla.org/dom/ .getService(Ci.nsIPaymentRequestService); ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.defineModuleGetter(this, "MasterPassword", "resource://formautofill/MasterPassword.jsm"); -XPCOMUtils.defineLazyGetter(this, "profileStorage", () => { - let profileStorage; +XPCOMUtils.defineLazyGetter(this, "formAutofillStorage", () => { + let formAutofillStorage; try { - profileStorage = ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm", {}) - .profileStorage; - profileStorage.initialize(); + formAutofillStorage = ChromeUtils.import("resource://formautofill/FormAutofillStorage.jsm", {}) + .formAutofillStorage; + formAutofillStorage.initialize(); } catch (ex) { - profileStorage = null; + formAutofillStorage = null; Cu.reportError(ex); } - return profileStorage; + return formAutofillStorage; }); var paymentDialogWrapper = { componentsLoaded: new Map(), frame: null, mm: null, request: null, QueryInterface: XPCOMUtils.generateQI([ Ci.nsIObserver, Ci.nsISupportsWeakReference, ]), /** - * Note: This method is async because profileStorage plans to become async. + * Note: This method is async because formAutofillStorage plans to become async. * * @param {string} guid * @returns {nsIPaymentAddress} */ async _convertProfileAddressToPaymentAddress(guid) { - let addressData = profileStorage.addresses.get(guid); + let addressData = formAutofillStorage.addresses.get(guid); if (!addressData) { throw new Error(`Shipping address not found: ${guid}`); } let address = this.createPaymentAddress({ country: addressData.country, addressLines: addressData["street-address"].split("\n"), region: addressData["address-level1"], @@ -72,17 +72,17 @@ var paymentDialogWrapper = { /** * @param {string} guid The GUID of the basic card record from storage. * @param {string} cardSecurityCode The associated card security code (CVV/CCV/etc.) * @throws if the user cancels entering their master password or an error decrypting * @returns {nsIBasicCardResponseData?} returns response data or null (if the * master password dialog was cancelled); */ async _convertProfileBasicCardToPaymentMethodData(guid, cardSecurityCode) { - let cardData = profileStorage.creditCards.get(guid); + let cardData = formAutofillStorage.creditCards.get(guid); if (!cardData) { throw new Error(`Basic card not found in storage: ${guid}`); } let cardNumber; try { cardNumber = await MasterPassword.decrypt(cardData["cc-number-encrypted"], true); } catch (ex) { @@ -217,25 +217,25 @@ var paymentDialogWrapper = { this.componentsLoaded.set(componentName, component); } return component.createInstance(componentInterface); }, fetchSavedAddresses() { let savedAddresses = {}; - for (let address of profileStorage.addresses.getAll()) { + for (let address of formAutofillStorage.addresses.getAll()) { savedAddresses[address.guid] = address; } return savedAddresses; }, fetchSavedPaymentCards() { let savedBasicCards = {}; - for (let card of profileStorage.creditCards.getAll()) { + for (let card of formAutofillStorage.creditCards.getAll()) { savedBasicCards[card.guid] = card; // Filter out the encrypted card number since the dialog content is // considered untrusted and runs in a content process. delete card["cc-number-encrypted"]; } return savedBasicCards; },
--- a/toolkit/components/payments/test/browser/browser_change_shipping.js +++ b/toolkit/components/payments/test/browser/browser_change_shipping.js @@ -1,25 +1,25 @@ "use strict"; add_task(async function setup_profiles() { let onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - profileStorage.addresses.add(PTU.Addresses.TimBL); + formAutofillStorage.addresses.add(PTU.Addresses.TimBL); await onChanged; onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - profileStorage.addresses.add(PTU.Addresses.TimBL2); + formAutofillStorage.addresses.add(PTU.Addresses.TimBL2); await onChanged; onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - profileStorage.creditCards.add(PTU.BasicCards.JohnDoe); + formAutofillStorage.creditCards.add(PTU.BasicCards.JohnDoe); await onChanged; }); add_task(async function test_change_shipping() { await BrowserTestUtils.withNewTab({ gBrowser, url: BLANK_PAGE_URL, }, async browser => {
--- a/toolkit/components/payments/test/browser/browser_profile_storage.js +++ b/toolkit/components/payments/test/browser/browser_profile_storage.js @@ -4,34 +4,34 @@ /* eslint-disable mozilla/no-cpows-in-tests */ const methodData = [PTU.MethodData.basicCard]; const details = PTU.Details.total60USD; add_task(async function test_initial_state() { let onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - let address1GUID = profileStorage.addresses.add({ + let address1GUID = formAutofillStorage.addresses.add({ "given-name": "Timothy", "additional-name": "John", "family-name": "Berners-Lee", organization: "World Wide Web Consortium", "street-address": "32 Vassar Street\nMIT Room 32-G524", "address-level2": "Cambridge", "address-level1": "MA", "postal-code": "02139", country: "US", tel: "+16172535702", email: "timbl@w3.org", }); await onChanged; onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - let card1GUID = profileStorage.creditCards.add({ + let card1GUID = formAutofillStorage.creditCards.add({ "cc-name": "John Doe", "cc-number": "1234567812345678", "cc-exp-month": 4, "cc-exp-year": 2028, }); await onChanged; await BrowserTestUtils.withNewTab({ @@ -67,17 +67,17 @@ add_task(async function test_initial_sta }, { address1GUID, card1GUID, }); let onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); info("adding an address"); - let address2GUID = profileStorage.addresses.add({ + let address2GUID = formAutofillStorage.addresses.add({ "given-name": "John", "additional-name": "", "family-name": "Smith", "street-address": "331 E. Evelyn Ave.", "address-level2": "Mountain View", "address-level1": "CA", "postal-code": "94041", country: "US", @@ -109,17 +109,17 @@ add_task(async function test_initial_sta address1GUID, address2GUID, card1GUID, }); onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "update"); info("updating the credit expiration"); - profileStorage.creditCards.update(card1GUID, { + formAutofillStorage.creditCards.update(card1GUID, { "cc-exp-month": 6, "cc-exp-year": 2029, }, true); await onChanged; await spawnPaymentDialogTask(frame, async function checkUpdate({ address1GUID, address2GUID, @@ -147,17 +147,17 @@ add_task(async function test_initial_sta address1GUID, address2GUID, card1GUID, }); onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "remove"); info("removing the first address"); - profileStorage.addresses.remove(address1GUID); + formAutofillStorage.addresses.remove(address1GUID); await onChanged; await spawnPaymentDialogTask(frame, async function checkRemove({ address2GUID, card1GUID, }) { info("checkRemove"); let contentWin = Cu.waiveXrays(content);
--- a/toolkit/components/payments/test/browser/browser_request_shipping.js +++ b/toolkit/components/payments/test/browser/browser_request_shipping.js @@ -6,17 +6,17 @@ add_task(async function setup() { let card = { "cc-exp-month": 1, "cc-exp-year": 9999, "cc-name": "John Doe", "cc-number": "999999999999", }; - profileStorage.creditCards.add(card); + formAutofillStorage.creditCards.add(card); await onChanged; }); add_task(async function test_request_shipping_present() { await BrowserTestUtils.withNewTab({ gBrowser, url: BLANK_PAGE_URL, }, async browser => {
--- a/toolkit/components/payments/test/browser/browser_show_dialog.js +++ b/toolkit/components/payments/test/browser/browser_show_dialog.js @@ -51,29 +51,29 @@ add_task(async function test_show_comple "street-address": "32 Vassar Street\nMIT Room 32-G524", "address-level2": "Cambridge", "address-level1": "MA", "postal-code": "02139", country: "US", tel: "+16172535702", email: "timbl@example.org", }; - profileStorage.addresses.add(address); + formAutofillStorage.addresses.add(address); await onChanged; onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); let card = { "cc-exp-month": 1, "cc-exp-year": 9999, "cc-name": "John Doe", "cc-number": "999999999999", }; - profileStorage.creditCards.add(card); + formAutofillStorage.creditCards.add(card); await onChanged; await BrowserTestUtils.withNewTab({ gBrowser, url: BLANK_PAGE_URL, }, async browser => { let {win, frame} = await setupPaymentDialog(browser, {
--- a/toolkit/components/payments/test/browser/head.js +++ b/toolkit/components/payments/test/browser/head.js @@ -10,17 +10,17 @@ const BLANK_PAGE_PATH = "/browser/toolkit/components/payments/test/browser/blank_page.html"; const BLANK_PAGE_URL = "https://example.com" + BLANK_PAGE_PATH; const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"] .getService(Ci.nsIPaymentRequestService); const paymentUISrv = Cc["@mozilla.org/dom/payments/payment-ui-service;1"] .getService().wrappedJSObject; -const {profileStorage} = ChromeUtils.import( +const {formAutofillStorage} = ChromeUtils.import( "resource://formautofill/FormAutofillStorage.jsm", {}); const {PaymentTestUtils: PTU} = ChromeUtils.import( "resource://testing-common/PaymentTestUtils.jsm", {}); function getPaymentRequests() { let requestsEnum = paymentSrv.enumerate(); let requests = []; while (requestsEnum.hasMoreElements()) { @@ -129,27 +129,27 @@ function spawnTaskInNewDialog(requestId, return withNewDialogFrame(requestId, async function spawnTaskInNewDialog_tabTask(reqFrame) { await spawnPaymentDialogTask(reqFrame, contentTaskFn, args); }); } async function addSampleAddressesAndBasicCard() { let onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - profileStorage.addresses.add(PTU.Addresses.TimBL); + formAutofillStorage.addresses.add(PTU.Addresses.TimBL); await onChanged; onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - profileStorage.addresses.add(PTU.Addresses.TimBL2); + formAutofillStorage.addresses.add(PTU.Addresses.TimBL2); await onChanged; onChanged = TestUtils.topicObserved("formautofill-storage-changed", (subject, data) => data == "add"); - profileStorage.creditCards.add(PTU.BasicCards.JohnDoe); + formAutofillStorage.creditCards.add(PTU.BasicCards.JohnDoe); await onChanged; } /** * Create a PaymentRequest object with the given parameters, then * run the given merchantTaskFn. * * @param {Object} browser @@ -212,15 +212,15 @@ async function spawnInDialogForMerchantT let request = requests[0]; ok(!!request.requestId, "Got a payment request with an ID"); await spawnTaskInNewDialog(request.requestId, dialogTaskFn, taskArgs); }); } add_task(async function setup_head() { - await profileStorage.initialize(); + await formAutofillStorage.initialize(); registerCleanupFunction(function cleanup() { paymentSrv.cleanup(); - profileStorage.addresses._nukeAllRecords(); - profileStorage.creditCards._nukeAllRecords(); + formAutofillStorage.addresses._nukeAllRecords(); + formAutofillStorage.creditCards._nukeAllRecords(); }); });
--- a/tools/lint/eslint/modules.json +++ b/tools/lint/eslint/modules.json @@ -154,17 +154,17 @@ "PdfJsNetwork.jsm": ["NetworkManager"], "PhoneNumberMetaData.jsm": ["PHONE_NUMBER_META_DATA"], "PlacesUtils.jsm": ["PlacesUtils"], "PluginProvider.jsm": [], "PointerAdapter.jsm": ["PointerRelay", "PointerAdapter"], "policies.js": ["ErrorHandler", "SyncScheduler"], "prefs.js": ["PrefsEngine", "PrefRec"], "prefs.jsm": ["Preference"], - "FormAutofillStorage.jsm": ["profileStorage"], + "FormAutofillStorage.jsm": ["formAutofillStorage"], "PromiseWorker.jsm": ["BasePromiseWorker"], "PushCrypto.jsm": ["PushCrypto", "concatArray"], "quit.js": ["goQuitApplication"], "Readability.js": ["Readability"], "record.js": ["WBORecord", "RecordManager", "CryptoWrapper", "CollectionKeyManager", "Collection"], "recursive_importA.jsm": ["foo", "bar"], "recursive_importB.jsm": ["baz", "qux"], "reflect.jsm": ["Reflect"],