summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'browser/extensions/formautofill/test/unit')
-rw-r--r--browser/extensions/formautofill/test/unit/test_addressComponent_state.js12
-rw-r--r--browser/extensions/formautofill/test/unit/test_getRecords.js28
-rw-r--r--browser/extensions/formautofill/test/unit/test_phoneNumber.js2
-rw-r--r--browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js93
4 files changed, 87 insertions, 48 deletions
diff --git a/browser/extensions/formautofill/test/unit/test_addressComponent_state.js b/browser/extensions/formautofill/test/unit/test_addressComponent_state.js
index 41d83e78c9..4e4c390008 100644
--- a/browser/extensions/formautofill/test/unit/test_addressComponent_state.js
+++ b/browser/extensions/formautofill/test/unit/test_addressComponent_state.js
@@ -7,14 +7,26 @@ const VALID_TESTS = [
["CA", true],
["CA.", true],
["CC", false],
+
+ // change region to CA
+ { region: "CA" },
+ ["BC", true],
+ ["British Columbia", true],
+ ["CA-BC", true],
];
const COMPARE_TESTS = [
["California", "california", SAME], // case insensitive
["CA", "california", SAME],
["CA", "ca", SAME],
+ ["CA", "CA.", SAME],
["California", "New Jersey", DIFFERENT],
["New York", "New Jersey", DIFFERENT],
+
+ // change region to CA
+ { region: "CA" },
+ ["British Columbia", "BC", SAME],
+ ["CA-BC", "BC", SAME],
];
const TEST_FIELD_NAME = "address-level1";
diff --git a/browser/extensions/formautofill/test/unit/test_getRecords.js b/browser/extensions/formautofill/test/unit/test_getRecords.js
index 9a7e5e6ac7..1ecbccab22 100644
--- a/browser/extensions/formautofill/test/unit/test_getRecords.js
+++ b/browser/extensions/formautofill/test/unit/test_getRecords.js
@@ -85,7 +85,7 @@ add_task(async function test_getRecords() {
sinon.stub(collection, "getAll");
collection.getAll.returns(Promise.resolve(expectedResult));
}
- await FormAutofillParent._getRecords({ collectionName });
+ await FormAutofillParent.getRecords({ collectionName });
if (collection) {
Assert.equal(collection.getAll.called, true);
collection.getAll.restore();
@@ -105,7 +105,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string could match 1 address",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: "Some",
},
expectedResult: [TEST_ADDRESS_2],
@@ -114,7 +114,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string could match multiple addresses",
filter: {
collectionName: "addresses",
- info: { fieldName: "country" },
+ fieldName: "country",
searchString: "u",
},
expectedResult: [TEST_ADDRESS_1, TEST_ADDRESS_2],
@@ -123,7 +123,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string could not match any address",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: "test",
},
expectedResult: [],
@@ -132,7 +132,7 @@ add_task(async function test_getRecords_addresses() {
description: "If the search string is empty",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: "",
},
expectedResult: [TEST_ADDRESS_1, TEST_ADDRESS_2],
@@ -142,7 +142,7 @@ add_task(async function test_getRecords_addresses() {
"Check if the filtering logic is free from searching special chars",
filter: {
collectionName: "addresses",
- info: { fieldName: "street-address" },
+ fieldName: "street-address",
searchString: ".*",
},
expectedResult: [],
@@ -152,7 +152,7 @@ add_task(async function test_getRecords_addresses() {
"Prevent broken while searching the property that does not exist",
filter: {
collectionName: "addresses",
- info: { fieldName: "tel" },
+ fieldName: "tel",
searchString: "1",
},
expectedResult: [],
@@ -161,7 +161,7 @@ add_task(async function test_getRecords_addresses() {
for (let testCase of testCases) {
info("Starting testcase: " + testCase.description);
- let result = await FormAutofillParent._getRecords(testCase.filter);
+ let result = await FormAutofillParent.getRecords(testCase.filter);
Assert.deepEqual(result, testCase.expectedResult);
}
});
@@ -195,7 +195,7 @@ add_task(async function test_getRecords_creditCards() {
description: "If the search string could match multiple creditCards",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-name" },
+ fieldName: "cc-name",
searchString: "John",
},
expectedResult: encryptedCCRecords,
@@ -204,7 +204,7 @@ add_task(async function test_getRecords_creditCards() {
description: "If the search string could not match any creditCard",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-name" },
+ fieldName: "cc-name",
searchString: "T",
},
expectedResult: [],
@@ -215,7 +215,7 @@ add_task(async function test_getRecords_creditCards() {
"if the search string could match multiple creditCards",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-number" },
+ fieldName: "cc-number",
searchString: "4",
},
expectedResult: encryptedCCRecords,
@@ -224,7 +224,7 @@ add_task(async function test_getRecords_creditCards() {
description: "If the search string could match 1 creditCard",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-name" },
+ fieldName: "cc-name",
searchString: "John Doe",
},
mpEnabled: true,
@@ -234,7 +234,7 @@ add_task(async function test_getRecords_creditCards() {
description: "Return all creditCards if focused field is cc number",
filter: {
collectionName: "creditCards",
- info: { fieldName: "cc-number" },
+ fieldName: "cc-number",
searchString: "411",
},
mpEnabled: true,
@@ -252,7 +252,7 @@ add_task(async function test_getRecords_creditCards() {
token.reset();
token.initPassword("password");
}
- let result = await FormAutofillParent._getRecords(testCase.filter);
+ let result = await FormAutofillParent.getRecords(testCase.filter);
Assert.deepEqual(result, testCase.expectedResult);
}
});
diff --git a/browser/extensions/formautofill/test/unit/test_phoneNumber.js b/browser/extensions/formautofill/test/unit/test_phoneNumber.js
index 133e54f6d7..b776bfd8b5 100644
--- a/browser/extensions/formautofill/test/unit/test_phoneNumber.js
+++ b/browser/extensions/formautofill/test/unit/test_phoneNumber.js
@@ -1,5 +1,5 @@
/**
- * Tests PhoneNumber.jsm and PhoneNumberNormalizer.jsm.
+ * Tests PhoneNumber.sys.mjs and PhoneNumberNormalizer.sys.mjs.
*/
"use strict";
diff --git a/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js b/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
index 7200bc8975..30cdae3d8a 100644
--- a/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
+++ b/browser/extensions/formautofill/test/unit/test_profileAutocompleteResult.js
@@ -51,6 +51,15 @@ let allFieldNames = [
"tel",
];
+function makeAddressLabel({ primary, secondary, status }) {
+ return JSON.stringify({
+ primary,
+ secondary,
+ status,
+ ariaLabel: primary + " " + secondary + " " + status,
+ });
+}
+
let addressTestCases = [
{
description: "Focus on an `organization` field",
@@ -65,21 +74,23 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "Sesame Street",
secondary: "123 Sesame Street.",
+ status: "Also autofills address, name, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "Mozilla",
secondary: "331 E. Evelyn Avenue",
+ status: "Also autofills address, name, phone",
}),
image: "",
},
@@ -99,31 +110,34 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "1-345-345-3456.",
secondary: "123 Sesame Street.",
+ status: "Also autofills address, name, organization",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "1-650-903-0800",
secondary: "331 E. Evelyn Avenue",
+ status: "Also autofills address, name, organization",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "1-000-000-0000",
secondary: "321, No Name St. 2nd line 3rd line",
+ status: "Also autofills address",
}),
image: "",
},
@@ -143,31 +157,34 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "123 Sesame Street.",
secondary: "Timothy Berners-Lee",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "331 E. Evelyn Avenue",
secondary: "John Doe",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "321, No Name St. 2nd line 3rd line",
secondary: "1-000-000-0000",
+ status: "Also autofills phone",
}),
image: "",
},
@@ -187,31 +204,34 @@ let addressTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "123 Sesame Street.",
secondary: "Timothy Berners-Lee",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "331 E. Evelyn Avenue",
secondary: "John Doe",
+ status: "Also autofills name, organization, phone",
}),
image: "",
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
- label: JSON.stringify({
+ label: makeAddressLabel({
primary: "321, No Name St.",
secondary: "1-000-000-0000",
+ status: "Also autofills phone",
}),
image: "",
},
@@ -287,11 +307,11 @@ let creditCardTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
label: JSON.stringify({
primary: "Timothy Berners-Lee",
- secondary: "****6785",
+ secondary: "••••6785",
ariaLabel: "Visa Timothy Berners-Lee ****6785",
image: "chrome://formautofill/content/third-party/cc-logo-visa.svg",
}),
@@ -299,11 +319,11 @@ let creditCardTestCases = [
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
label: JSON.stringify({
primary: "John Doe",
- secondary: "****1234",
+ secondary: "••••1234",
ariaLabel: "American Express John Doe ****1234",
image: "chrome://formautofill/content/third-party/cc-logo-amex.png",
}),
@@ -325,10 +345,10 @@ let creditCardTestCases = [
items: [
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[0]),
label: JSON.stringify({
- primary: "****6785",
+ primary: "••••6785",
secondary: "Timothy Berners-Lee",
ariaLabel: "Visa 6785 Timothy Berners-Lee",
image: "chrome://formautofill/content/third-party/cc-logo-visa.svg",
@@ -337,10 +357,10 @@ let creditCardTestCases = [
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[1]),
label: JSON.stringify({
- primary: "****1234",
+ primary: "••••1234",
secondary: "John Doe",
ariaLabel: "American Express 1234 John Doe",
image: "chrome://formautofill/content/third-party/cc-logo-amex.png",
@@ -349,10 +369,10 @@ let creditCardTestCases = [
},
{
value: "",
- style: "autofill-profile",
+ style: "autofill",
comment: JSON.stringify(matchingProfiles[2]),
label: JSON.stringify({
- primary: "****5678",
+ primary: "••••5678",
secondary: "",
ariaLabel: "5678",
image: "chrome://formautofill/content/icon-credit-card-generic.svg",
@@ -416,7 +436,14 @@ add_task(async function test_all_patterns() {
let expectedItemLength = expectedValue.items.length;
// If the last item shows up as a footer, we expect one more item
// than expected.
- if (actual.getStyleAt(actual.matchCount - 1) == "autofill-footer") {
+ if (actual.getStyleAt(actual.matchCount - 1) == "action") {
+ expectedItemLength++;
+ }
+ // Add one row for the status.
+ if (
+ actual.matchCount > 2 &&
+ actual.getStyleAt(actual.matchCount - 2) == "status"
+ ) {
expectedItemLength++;
}