diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-03 06:00:38 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-03 06:00:38 -0500 |
commit | 8148615da179fdd60f19018e13b4e94b95609cc6 (patch) | |
tree | 771fccdd99fa3adf35fdd2c81d8197b415a89b91 /browser/extensions/formautofill/test/unit/test_populateFieldValues.js | |
parent | 494802c1be7888025b95260d23db187467d2b9dd (diff) | |
download | UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.gz UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.lz UXP-8148615da179fdd60f19018e13b4e94b95609cc6.tar.xz UXP-8148615da179fdd60f19018e13b4e94b95609cc6.zip |
Remove browser tests - Part 1: The Tests (except for experiments)
Diffstat (limited to 'browser/extensions/formautofill/test/unit/test_populateFieldValues.js')
-rw-r--r-- | browser/extensions/formautofill/test/unit/test_populateFieldValues.js | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/browser/extensions/formautofill/test/unit/test_populateFieldValues.js b/browser/extensions/formautofill/test/unit/test_populateFieldValues.js deleted file mode 100644 index 1215cbd16..000000000 --- a/browser/extensions/formautofill/test/unit/test_populateFieldValues.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Test for populating field values in Form Autofill Parent. - */ - -/* global FormAutofillParent */ - -"use strict"; - -importAutofillModule("FormAutofillParent.jsm"); - -do_get_profile(); - -const TEST_FIELDS = [ - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "organization"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "street-address"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level2"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "address-level1"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "postal-code"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "country"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "tel"}, - {"section": "", "addressType": "shipping", "contactType": "", "fieldName": "email"}, -]; - -const TEST_GUID = "test-guid"; - -const TEST_PROFILE = { - guid: TEST_GUID, - organization: "World Wide Web Consortium", - streetAddress: "32 Vassar Street\nMIT Room 32-G524", - addressLevel2: "Cambridge", - addressLevel1: "MA", - postalCode: "02139", - country: "US", - tel: "+1 617 253 5702", - email: "timbl@w3.org", -}; - -function camelCase(str) { - return str.toLowerCase().replace(/-([a-z])/g, s => s[1].toUpperCase()); -} - -add_task(function* test_populateFieldValues() { - FormAutofillParent.init(); - - let store = FormAutofillParent.getProfileStore(); - do_check_neq(store, null); - - store.get = function(guid) { - do_check_eq(guid, TEST_GUID); - return store._clone(TEST_PROFILE); - }; - - let notifyUsedCalledCount = 0; - store.notifyUsed = function(guid) { - do_check_eq(guid, TEST_GUID); - notifyUsedCalledCount++; - }; - - yield new Promise((resolve) => { - FormAutofillParent.receiveMessage({ - name: "FormAutofill:PopulateFieldValues", - data: { - guid: TEST_GUID, - fields: TEST_FIELDS, - }, - target: { - sendAsyncMessage: function(name, data) { - do_check_eq(name, "FormAutofill:fillForm"); - - let fields = data.fields; - do_check_eq(fields.length, TEST_FIELDS.length); - - for (let i = 0; i < fields.length; i++) { - do_check_eq(fields[i].fieldName, TEST_FIELDS[i].fieldName); - do_check_eq(fields[i].value, - TEST_PROFILE[camelCase(fields[i].fieldName)]); - } - - resolve(); - }, - }, - }); - }); - - do_check_eq(notifyUsedCalledCount, 1); - - FormAutofillParent._uninit(); - do_check_null(FormAutofillParent.getProfileStore()); -}); - -add_task(function* test_populateFieldValues_with_invalid_guid() { - FormAutofillParent.init(); - - Assert.throws(() => { - FormAutofillParent.receiveMessage({ - name: "FormAutofill:PopulateFieldValues", - data: { - guid: "invalid-guid", - fields: TEST_FIELDS, - }, - target: {}, - }); - }, /No matching profile\./); - - FormAutofillParent._uninit(); -}); |