зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434483 - Renamed profileStorage singleton to formAutofillStorage to make it more clear; r=MattN
MozReview-Commit-ID: CaPYBGLfs5I --HG-- extra : rebase_source : ea59d03458c0e253201fd2c1476062dfb2e9a3d6
This commit is contained in:
Родитель
2eaf293b17
Коммит
d337129b4a
|
@ -125,8 +125,8 @@ class TestFirefoxRefresh(MarionetteTestCase):
|
|||
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);
|
||||
""")
|
||||
|
||||
|
@ -281,8 +281,8 @@ class TestFirefoxRefresh(MarionetteTestCase):
|
|||
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:
|
||||
|
@ -424,7 +424,7 @@ class TestFirefoxRefresh(MarionetteTestCase):
|
|||
""")
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -57,16 +57,16 @@ const {
|
|||
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;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ FormAutofillParent.prototype = {
|
|||
async receiveMessage({name, data, target}) {
|
||||
switch (name) {
|
||||
case "FormAutofill:InitStorage": {
|
||||
this.profileStorage.initialize();
|
||||
this.formAutofillStorage.initialize();
|
||||
break;
|
||||
}
|
||||
case "FormAutofill:GetRecords": {
|
||||
|
@ -214,9 +214,9 @@ FormAutofillParent.prototype = {
|
|||
}
|
||||
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;
|
||||
}
|
||||
|
@ -227,15 +227,15 @@ FormAutofillParent.prototype = {
|
|||
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": {
|
||||
|
@ -270,7 +270,7 @@ FormAutofillParent.prototype = {
|
|||
* @private
|
||||
*/
|
||||
_uninit() {
|
||||
this.profileStorage._saveImmediately();
|
||||
this.formAutofillStorage._saveImmediately();
|
||||
|
||||
Services.ppmm.removeMessageListener("FormAutofill:InitStorage", this);
|
||||
Services.ppmm.removeMessageListener("FormAutofill:GetRecords", this);
|
||||
|
@ -303,7 +303,7 @@ FormAutofillParent.prototype = {
|
|||
* 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;
|
||||
|
@ -360,7 +360,7 @@ FormAutofillParent.prototype = {
|
|||
}
|
||||
|
||||
["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;
|
||||
|
@ -371,7 +371,7 @@ FormAutofillParent.prototype = {
|
|||
});
|
||||
|
||||
// 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);
|
||||
});
|
||||
|
||||
|
@ -384,51 +384,51 @@ FormAutofillParent.prototype = {
|
|||
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
|
||||
|
@ -468,7 +468,7 @@ FormAutofillParent.prototype = {
|
|||
// 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]) {
|
||||
|
@ -485,7 +485,7 @@ FormAutofillParent.prototype = {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -506,9 +506,9 @@ FormAutofillParent.prototype = {
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -544,18 +544,18 @@ FormAutofillParent.prototype = {
|
|||
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));
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
|
||||
// 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");
|
||||
|
@ -1802,5 +1802,5 @@ FormAutofillStorage.prototype = {
|
|||
};
|
||||
|
||||
// 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));
|
||||
|
|
|
@ -16,7 +16,7 @@ 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.
|
||||
|
@ -57,7 +57,7 @@ AutofillRecord.prototype = {
|
|||
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;
|
||||
},
|
||||
|
@ -84,7 +84,7 @@ FormAutofillStore.prototype = {
|
|||
|
||||
get storage() {
|
||||
if (!this._storage) {
|
||||
this._storage = profileStorage[this._subStorageName];
|
||||
this._storage = formAutofillStorage[this._subStorageName];
|
||||
}
|
||||
return this._storage;
|
||||
},
|
||||
|
@ -102,7 +102,7 @@ FormAutofillStore.prototype = {
|
|||
},
|
||||
|
||||
// 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));
|
||||
},
|
||||
|
@ -291,7 +291,7 @@ FormAutofillEngine.prototype = {
|
|||
// 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);
|
||||
},
|
||||
|
||||
|
@ -329,7 +329,7 @@ FormAutofillEngine.prototype = {
|
|||
},
|
||||
|
||||
async _resetClient() {
|
||||
await profileStorage.initialize();
|
||||
await formAutofillStorage.initialize();
|
||||
this._store.storage.resetSync();
|
||||
},
|
||||
};
|
||||
|
|
|
@ -13,14 +13,14 @@ 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;
|
||||
|
@ -75,7 +75,7 @@ class EditDialog {
|
|||
*/
|
||||
async getStorage() {
|
||||
await this._storageInitPromise;
|
||||
return profileStorage[this._subStorageName];
|
||||
return formAutofillStorage[this._subStorageName];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ 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");
|
||||
|
@ -24,7 +24,7 @@ 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;
|
||||
|
@ -67,7 +67,7 @@ class ManageRecords {
|
|||
*/
|
||||
async getStorage() {
|
||||
await this._storageInitPromise;
|
||||
return profileStorage[this._subStorageName];
|
||||
return formAutofillStorage[this._subStorageName];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
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;
|
||||
|
||||
|
@ -113,13 +113,13 @@ var ParentUtils = {
|
|||
},
|
||||
|
||||
_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;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ add_task(async function test_activeStatus_init() {
|
|||
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);
|
||||
|
@ -71,8 +71,8 @@ add_task(async function test_activeStatus_computeStatus() {
|
|||
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);
|
||||
|
@ -84,7 +84,7 @@ add_task(async function test_activeStatus_computeStatus() {
|
|||
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);
|
||||
|
|
|
@ -49,7 +49,7 @@ 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",
|
||||
|
@ -66,7 +66,7 @@ add_task(async function test_getRecords() {
|
|||
};
|
||||
|
||||
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);
|
||||
|
@ -88,9 +88,9 @@ 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);
|
||||
|
||||
|
@ -165,8 +165,8 @@ 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"]);
|
||||
|
|
|
@ -12,7 +12,7 @@ add_task(async function test_profileSavedFieldNames_init() {
|
|||
sinon.stub(formAutofillParent, "_updateSavedFieldNames");
|
||||
|
||||
await formAutofillParent.init();
|
||||
await formAutofillParent.profileStorage.initialize();
|
||||
await formAutofillParent.formAutofillStorage.initialize();
|
||||
Assert.equal(formAutofillParent._updateSavedFieldNames.called, true);
|
||||
|
||||
formAutofillParent._uninit();
|
||||
|
@ -43,8 +43,8 @@ add_task(async function test_profileSavedFieldNames_update() {
|
|||
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();
|
||||
|
@ -72,7 +72,7 @@ add_task(async function test_profileSavedFieldNames_update() {
|
|||
timeLastModified: 0,
|
||||
timesUsed: 0,
|
||||
}];
|
||||
profileStorage.addresses.getAll.returns(fakeStorage);
|
||||
formAutofillParent.formAutofillStorage.addresses.getAll.returns(fakeStorage);
|
||||
formAutofillParent._updateSavedFieldNames();
|
||||
|
||||
let autofillSavedFieldNames = Services.ppmm.initialProcessData.autofillSavedFieldNames;
|
||||
|
|
|
@ -29,7 +29,7 @@ class FormAutofillBase {
|
|||
}
|
||||
|
||||
get storage() {
|
||||
return profileStorage[this._subStorageName];
|
||||
return formAutofillStorage[this._subStorageName];
|
||||
}
|
||||
|
||||
Create() {
|
||||
|
@ -55,7 +55,7 @@ class FormAutofillBase {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -18,18 +18,18 @@ 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 = {
|
||||
|
@ -44,13 +44,13 @@ var paymentDialogWrapper = {
|
|||
]),
|
||||
|
||||
/**
|
||||
* 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}`);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ var paymentDialogWrapper = {
|
|||
* 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}`);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ var paymentDialogWrapper = {
|
|||
|
||||
fetchSavedAddresses() {
|
||||
let savedAddresses = {};
|
||||
for (let address of profileStorage.addresses.getAll()) {
|
||||
for (let address of formAutofillStorage.addresses.getAll()) {
|
||||
savedAddresses[address.guid] = address;
|
||||
}
|
||||
return savedAddresses;
|
||||
|
@ -230,7 +230,7 @@ var paymentDialogWrapper = {
|
|||
|
||||
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.
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
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;
|
||||
});
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ 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",
|
||||
|
@ -26,7 +26,7 @@ add_task(async function test_initial_state() {
|
|||
|
||||
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,
|
||||
|
@ -72,7 +72,7 @@ add_task(async function test_initial_state() {
|
|||
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",
|
||||
|
@ -114,7 +114,7 @@ add_task(async function test_initial_state() {
|
|||
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);
|
||||
|
@ -152,7 +152,7 @@ add_task(async function test_initial_state() {
|
|||
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({
|
||||
|
|
|
@ -11,7 +11,7 @@ add_task(async function setup() {
|
|||
"cc-number": "999999999999",
|
||||
};
|
||||
|
||||
profileStorage.creditCards.add(card);
|
||||
formAutofillStorage.creditCards.add(card);
|
||||
await onChanged;
|
||||
});
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ add_task(async function test_show_completePayment() {
|
|||
tel: "+16172535702",
|
||||
email: "timbl@example.org",
|
||||
};
|
||||
profileStorage.addresses.add(address);
|
||||
formAutofillStorage.addresses.add(address);
|
||||
await onChanged;
|
||||
|
||||
onChanged = TestUtils.topicObserved("formautofill-storage-changed",
|
||||
|
@ -68,7 +68,7 @@ add_task(async function test_show_completePayment() {
|
|||
"cc-number": "999999999999",
|
||||
};
|
||||
|
||||
profileStorage.creditCards.add(card);
|
||||
formAutofillStorage.creditCards.add(card);
|
||||
await onChanged;
|
||||
|
||||
await BrowserTestUtils.withNewTab({
|
||||
|
|
|
@ -15,7 +15,7 @@ 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", {});
|
||||
|
@ -134,17 +134,17 @@ function spawnTaskInNewDialog(requestId, contentTaskFn, args = null) {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -217,10 +217,10 @@ async function spawnInDialogForMerchantTask(merchantTaskFn, dialogTaskFn, taskAr
|
|||
}
|
||||
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
"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"],
|
||||
|
|
Загрузка…
Ссылка в новой задаче