{ // We're going to register a mock file source // with region names based on en-US. This is // necessary for tests that expect to match // on region code display names. const fs = [
{
path: "toolkit/intl/regionNames.ftl",
source: `
region-name-us = United States
region-name-nz = New Zealand
region-name-au = Australia
region-name-ca = Canada
region-name-tw = Taiwan
`,
},
];
// Returns a reference to a temporary file that is guaranteed not to exist and // is cleaned up later. See FileTestUtils.getTempFile for details. function getTempFile(leafName) { return FileTestUtils.getTempFile(leafName);
}
async function initProfileStorage(
fileName,
records,
collectionName = "addresses"
) {
let { FormAutofillStorage } = ChromeUtils.importESModule( "resource://autofill/FormAutofillStorage.sys.mjs"
);
let path = getTempFile(fileName).path;
let profileStorage = new FormAutofillStorage(path);
await profileStorage.initialize();
// AddonTestUtils inserts its own directory provider that manages TmpD. // It removes that directory at shutdown, which races with shutdown // handing in JSONFile/DeferredTask (which is used by FormAutofillStorage). // Avoid the race by explicitly finalizing any formautofill JSONFile // instances created manually by individual tests when the test finishes.
registerCleanupFunction(function finalizeAutofillStorage() { return profileStorage._finalize();
});
if (!records || !Array.isArray(records)) { return profileStorage;
}
let onChanged = TestUtils.topicObserved( "formautofill-storage-changed",
(subject, data) =>
data == "add" && subject.wrappedJSObject.collectionName == collectionName
); for (let record of records) { Assert.ok(await profileStorage[collectionName].add(record));
await onChanged;
}
await profileStorage._saveImmediately(); return profileStorage;
}
Assert.equal(
expeceted.autofill,
field.element.value,
`Autofilled value for element(id=${field.element.id}, field name=${field.fieldName}) should be equal`
);
});
});
}
for (const key of keys) { const expectedValue = expected[key]; const actualValue = field[key]; Assert.equal(
expectedValue,
actualValue,
`${key} should be equal, expect ${expectedValue}, got ${actualValue}`
);
}
});
Assert.equal(
section.isValidSection(),
!expectedSection.invalid,
`Should be an ${expectedSection.invalid ? "invalid" : "valid"} section`
);
});
}
var LabelUtils; var AddressMetaDataLoader, FormAutofillUtils;
function autofillFieldSelector(doc) { return doc.querySelectorAll("input, select");
}
/** * Returns the Sync change counter for a profile storage record. Synced records * store additional metadata for tracking changes and resolving merge conflicts. * Deleting a synced record replaces the record with a tombstone. * * @param {AutofillRecords} records * The `AutofillRecords` instance to query. * @param {string} guid * The GUID of the record or tombstone. * @returns {number} * The change counter, or -1 if the record doesn't exist or hasn't * been synced yet.
*/ function getSyncChangeCounter(records, guid) {
let record = records._findByGUID(guid, { includeDeleted: true }); if (!record) { return -1;
}
let sync = records._getSyncMetaData(record); if (!sync) { return -1;
} return sync.changeCounter;
}
/** * Performs a partial deep equality check to determine if an object contains * the given fields. To ensure the object doesn't contain a property, set the * property of the `fields` object to `undefined` * * @param {object} object * The object to check. Unlike `ObjectUtils.deepEqual`, properties in * `object` that are not in `fields` will be ignored. * @param {object} fields * The fields to match. * @returns {boolean} * Does `object` contain `fields` with matching values?
*/ function objectMatches(object, fields) {
let actual = {}; for (const key in fields) { if (!object.hasOwnProperty(key)) { if (fields[key] != undefined) { returnfalse;
}
}
actual[key] = object[key];
} return ObjectUtils.deepEqual(actual, fields);
}
add_setup(async function head_initialize() {
Services.prefs.setBoolPref("extensions.experiments.enabled", true);
Services.prefs.setBoolPref("dom.forms.autocomplete.formautofill", true);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.