--- a/browser/extensions/formautofill/test/unit/test_collectFormFields.js
+++ b/browser/extensions/formautofill/test/unit/test_collectFormFields.js
@@ -19,23 +19,16 @@ const TESTCASES = [
description: "Form with autocomplete properties and 1 token",
document: `<form><input id="given-name" autocomplete="given-name">
<input id="family-name" autocomplete="family-name">
<input id="street-addr" autocomplete="street-address">
<input id="city" autocomplete="address-level2">
<input id="country" autocomplete="country">
<input id="email" autocomplete="email">
<input id="tel" autocomplete="tel"></form>`,
- returnedFormat: [
- {"section": "", "addressType": "", "contactType": "", "fieldName": "street-address", "index": 0},
- {"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2", "index": 1},
- {"section": "", "addressType": "", "contactType": "", "fieldName": "country", "index": 2},
- {"section": "", "addressType": "", "contactType": "", "fieldName": "email", "index": 3},
- {"section": "", "addressType": "", "contactType": "", "fieldName": "tel", "index": 4},
- ],
fieldDetails: [
{"section": "", "addressType": "", "contactType": "", "fieldName": "street-address", "element": {}},
{"section": "", "addressType": "", "contactType": "", "fieldName": "address-level2", "element": {}},
{"section": "", "addressType": "", "contactType": "", "fieldName": "country", "element": {}},
{"section": "", "addressType": "", "contactType": "", "fieldName": "email", "element": {}},
{"section": "", "addressType": "", "contactType": "", "fieldName": "tel", "element": {}},
],
},
@@ -43,23 +36,16 @@ const TESTCASES = [
description: "Form with autocomplete properties and 2 tokens",
document: `<form><input id="given-name" autocomplete="shipping given-name">
<input id="family-name" autocomplete="shipping family-name">
<input id="street-addr" autocomplete="shipping street-address">
<input id="city" autocomplete="shipping address-level2">
<input id="country" autocomplete="shipping country">
<input id='email' autocomplete="shipping email">
<input id="tel" autocomplete="shipping tel"></form>`,
- returnedFormat: [
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address", "index": 0},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2", "index": 1},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country", "index": 2},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email", "index": 3},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel", "index": 4},
- ],
fieldDetails: [
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel", "element": {}},
],
},
@@ -67,23 +53,16 @@ const TESTCASES = [
description: "Form with autocomplete properties and profile is partly matched",
document: `<form><input id="given-name" autocomplete="shipping given-name">
<input id="family-name" autocomplete="shipping family-name">
<input id="street-addr" autocomplete="shipping street-address">
<input id="city" autocomplete="shipping address-level2">
<input id="country" autocomplete="shipping country">
<input id='email' autocomplete="shipping email">
<input id="tel" autocomplete="shipping tel"></form>`,
- returnedFormat: [
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address", "index": 0},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2", "index": 1},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country", "index": 2},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email", "index": 3},
- {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel", "index": 4},
- ],
fieldDetails: [
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email", "element": {}},
{"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel", "element": {}},
],
},
@@ -95,16 +74,15 @@ for (let tc of TESTCASES) {
add_task(function* () {
do_print("Starting testcase: " + testcase.description);
let doc = MockDocument.createTestDocument("http://localhost:8080/test/",
testcase.document);
let form = doc.querySelector("form");
let handler = new FormAutofillHandler(form);
- Assert.deepEqual(handler.collectFormFields(), testcase.returnedFormat,
- "Check the format of form autofill were returned correctly");
+ handler.collectFormFields();
Assert.deepEqual(handler.fieldDetails, testcase.fieldDetails,
"Check the fieldDetails were set correctly");
});
})();
}