"use strict"; const DEFAULT_TEST_DOC = `
`; const TARGET_ELEMENT_ID = "street-addr"; const TESTCASES = [ { description: "Should not trigger address saving if the number of fields is less than 3", document: DEFAULT_TEST_DOC, targetElementId: TARGET_ELEMENT_ID, formValue: { "#street-addr": "331 E. Evelyn Avenue", "#tel": "1-650-903-0800", }, }, { description: "Should not trigger the address save doorhanger when pref off", document: DEFAULT_TEST_DOC, targetElementId: TARGET_ELEMENT_ID, formValue: { "#street-addr": "331 E. Evelyn Avenue", "#email": "test@mozilla.org", "#tel": "1-650-903-0800", }, prefs: [["extensions.formautofill.addresses.capture.enabled", false]], }, ]; add_setup(async function () { await SpecialPowers.pushPrefEnv({ set: [ ["extensions.formautofill.addresses.capture.enabled", true], ["extensions.formautofill.addresses.supported", "on"], ], }); }); add_task(async function test_save_doorhanger_not_shown() { for (const TEST of TESTCASES) { info(`Test ${TEST.description}`); if (TEST.prefs) { await SpecialPowers.pushPrefEnv({ set: TEST.prefs, }); } await BrowserTestUtils.withNewTab(EMPTY_URL, async function (browser) { await SpecialPowers.spawn(browser, [TEST.document], doc => { content.document.body.innerHTML = doc; }); await SimpleTest.promiseFocus(browser); await focusUpdateSubmitForm(browser, { focusSelector: `#${TEST.targetElementId}`, newValues: TEST.formValue, }); await ensureNoDoorhanger(browser); }); if (TEST.prefs) { await SpecialPowers.popPrefEnv(); } } });