"use strict"; const DEFAULT_TEST_DOC = `
`; const TESTCASES = [ { description: "Should not trigger credit card saving if number is empty", document: DEFAULT_TEST_DOC, targetElementId: "cc-name", formValue: { "#cc-name": "John Doe", "#cc-exp-month": 12, "#cc-exp-year": 2000, }, }, { description: "Should not trigger credit card saving if there is more than one cc-number field but less than four fields", document: `
`, targetElementId: "cc-name", formValue: { "#cc-name": "John Doe", "#cc-number1": "3714", "#cc-number2": "4963", "#cc-number3": "5398", "#cc-exp-month": 12, "#cc-exp-year": 2000, "#cc-type": "amex", }, }, ]; add_task(async function test_save_doorhanger_not_shown() { for (const TEST of TESTCASES) { info(`Test ${TEST.description}`); 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(); }); } });