summaryrefslogtreecommitdiffstats
path: root/browser/extensions/formautofill/test/browser/head.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/extensions/formautofill/test/browser/head.js')
-rw-r--r--browser/extensions/formautofill/test/browser/head.js71
1 files changed, 37 insertions, 34 deletions
diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js
index 8de8488f1f..d82ed5076e 100644
--- a/browser/extensions/formautofill/test/browser/head.js
+++ b/browser/extensions/formautofill/test/browser/head.js
@@ -1,5 +1,9 @@
"use strict";
+const { ManageAddresses } = ChromeUtils.importESModule(
+ "chrome://formautofill/content/manageDialog.mjs"
+);
+
const { OSKeyStore } = ChromeUtils.importESModule(
"resource://gre/modules/OSKeyStore.sys.mjs"
);
@@ -20,6 +24,27 @@ const { FormAutofillNameUtils } = ChromeUtils.importESModule(
"resource://gre/modules/shared/FormAutofillNameUtils.sys.mjs"
);
+const { FormAutofillUtils } = ChromeUtils.importESModule(
+ "resource://gre/modules/shared/FormAutofillUtils.sys.mjs"
+);
+
+let { sinon } = ChromeUtils.importESModule(
+ "resource://testing-common/Sinon.sys.mjs"
+);
+
+// Always pretend OS Auth is enabled in this dir.
+if (
+ gTestPath.includes("browser/creditCard") &&
+ OSKeyStoreTestUtils.canTestOSKeyStoreLogin() &&
+ OSKeyStore.canReauth()
+) {
+ info("Stubbing out getOSAuthEnabled so it always returns true");
+ sinon.stub(FormAutofillUtils, "getOSAuthEnabled").returns(true);
+ registerCleanupFunction(() => {
+ sinon.restore();
+ });
+}
+
const MANAGE_ADDRESSES_DIALOG_URL =
"chrome://formautofill/content/manageAddresses.xhtml";
const MANAGE_CREDIT_CARDS_DIALOG_URL =
@@ -535,25 +560,6 @@ async function runAndWaitForAutocompletePopupOpen(browser, taskFn) {
await taskFn();
await popupShown;
- await BrowserTestUtils.waitForMutationCondition(
- browser.autoCompletePopup.richlistbox,
- { childList: true, subtree: true, attributes: true },
- () => {
- const listItemElems = getDisplayedPopupItems(browser);
- return (
- !![...listItemElems].length &&
- [...listItemElems].every(item => {
- return (
- (item.getAttribute("originaltype") == "autofill-profile" ||
- item.getAttribute("originaltype") == "autofill-insecureWarning" ||
- item.getAttribute("originaltype") == "autofill-clear-button" ||
- item.getAttribute("originaltype") == "autofill-footer") &&
- item.hasAttribute("formautofillattached")
- );
- })
- );
- }
- );
}
async function waitForPopupEnabled(browser) {
@@ -595,7 +601,7 @@ function waitPopupStateInChild(bc, messageName) {
async function openPopupOn(browser, selector) {
let childNotifiedPromise = waitPopupStateInChild(
browser,
- "FormAutoComplete:PopupOpened"
+ "AutoComplete:PopupOpened"
);
await SimpleTest.promiseFocus(browser);
@@ -613,7 +619,7 @@ async function openPopupOn(browser, selector) {
async function openPopupOnSubframe(browser, frameBrowsingContext, selector) {
let childNotifiedPromise = waitPopupStateInChild(
frameBrowsingContext,
- "FormAutoComplete:PopupOpened"
+ "AutoComplete:PopupOpened"
);
await SimpleTest.promiseFocus(browser);
@@ -637,7 +643,7 @@ async function closePopup(browser) {
let childNotifiedPromise = waitPopupStateInChild(
browser,
- "FormAutoComplete:PopupClosed"
+ "AutoComplete:PopupClosed"
);
let popupClosePromise = BrowserTestUtils.waitForPopupEvent(
browser.autoCompletePopup,
@@ -655,7 +661,7 @@ async function closePopup(browser) {
async function closePopupForSubframe(browser, frameBrowsingContext) {
let childNotifiedPromise = waitPopupStateInChild(
browser,
- "FormAutoComplete:PopupClosed"
+ "AutoComplete:PopupClosed"
);
let popupClosePromise = BrowserTestUtils.waitForPopupEvent(
@@ -841,7 +847,7 @@ async function removeAllRecords() {
async function waitForFocusAndFormReady(win) {
return Promise.all([
new Promise(resolve => waitForFocus(resolve, win)),
- BrowserTestUtils.waitForEvent(win, "FormReady"),
+ BrowserTestUtils.waitForEvent(win, "FormReadyForTests"),
]);
}
@@ -850,14 +856,8 @@ async function expectWarningText(browser, expectedText) {
const {
autoCompletePopup: { richlistbox: itemsBox },
} = browser;
- let warningBox = itemsBox.querySelector(
- ".autocomplete-richlistitem:last-child"
- );
-
- while (warningBox.collapsed) {
- warningBox = warningBox.previousSibling;
- }
- warningBox = warningBox._warningTextBox;
+ let warningBox = itemsBox.querySelector(".ac-status");
+ ok(warningBox.parentNode.disabled, "Got warning box and is disabled");
await BrowserTestUtils.waitForMutationCondition(
warningBox,
@@ -880,9 +880,12 @@ async function testDialog(url, testFn, arg = undefined) {
"cc-number": await OSKeyStore.decrypt(arg.record["cc-number-encrypted"]),
});
}
- let win = window.openDialog(url, null, "width=600,height=600", arg);
+ const win = window.openDialog(url, null, "width=600,height=600", {
+ ...arg,
+ l10nStrings: ManageAddresses.getAddressL10nStrings(),
+ });
await waitForFocusAndFormReady(win);
- let unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
+ const unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
await testFn(win);
return unloadPromise;
}