/* * Test for LoginManagerContent._getPasswordFields using LoginFormFactory. */ "use strict"; const {LoginFormFactory} = ChromeUtils.import("resource://gre/modules/LoginFormFactory.jsm"); const LMCBackstagePass = ChromeUtils.import("resource://gre/modules/LoginManagerContent.jsm", null); const { LoginManagerContent } = LMCBackstagePass; const TESTCASES = [ { description: "Empty document", document: ``, returnedFieldIDsByFormLike: [], skipEmptyFields: undefined, }, { description: "Non-password input with no
`, returnedFieldIDsByFormLike: [["pw1"]], skipEmptyFields: undefined, }, { description: "Form with 2 password fields", document: ``, returnedFieldIDsByFormLike: [["pw1", "pw2"]], skipEmptyFields: undefined, }, { description: "1 password field in a form, 1 outside", document: ``, returnedFieldIDsByFormLike: [["pw1"], ["pw2"]], skipEmptyFields: undefined, }, { description: "2 password fields outside of a `, returnedFieldIDsByFormLike: [["pw1"], ["pw2"]], skipEmptyFields: undefined, }, { description: "2 password fields outside of a `, returnedFieldIDsByFormLike: [[], []], skipEmptyFields: true, }, { description: "skipEmptyFields should also skip white-space only fields", /* eslint-disable no-tabs */ document: ` `, /* eslint-disable no-tabs */ returnedFieldIDsByFormLike: [[], []], skipEmptyFields: true, }, { description: "2 password fields outside of a `, returnedFieldIDsByFormLike: [["pw1"], []], skipEmptyFields: true, fieldOverrideRecipe: { // Ensure a recipe without `notPasswordSelector` doesn't cause a problem. hosts: ["localhost:8080"], }, }, { description: "3 password fields outside of a `, returnedFieldIDsByFormLike: [["pw3"], ["pw2"]], skipEmptyFields: true, fieldOverrideRecipe: { hosts: ["localhost:8080"], notPasswordSelector: "#pw1", }, }, { beforeGetFunction(doc) { doc.getElementById("pw1").remove(); }, description: "1 password field outside of a