зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1430979 - Wait for focus event in addition to FormReady event in formautofill tests. r=MattN
This commit is contained in:
Родитель
006d377043
Коммит
dfb28054d0
|
@ -5,33 +5,33 @@
|
|||
add_task(async function test_cancelEditCreditCardDialog() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
win.addEventListener("load", () => {
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
win.document.querySelector("#cancel").click();
|
||||
}, {once: true});
|
||||
}, win);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_cancelEditCreditCardDialogWithESC() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
win.addEventListener("load", () => {
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed with ESC key");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
}, {once: true});
|
||||
}, win);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_saveCreditCard() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
win.addEventListener("load", () => {
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
|
@ -48,7 +48,7 @@ add_task(async function test_saveCreditCard() {
|
|||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
info("saving credit card");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
}, {once: true});
|
||||
}, win);
|
||||
});
|
||||
let creditCards = await getCreditCards();
|
||||
|
||||
|
@ -65,7 +65,7 @@ add_task(async function test_saveCreditCard() {
|
|||
add_task(async function test_saveCreditCardWithMaxYear() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
win.addEventListener("load", () => {
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
|
@ -82,7 +82,7 @@ add_task(async function test_saveCreditCardWithMaxYear() {
|
|||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
info("saving credit card");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
}, {once: true});
|
||||
}, win);
|
||||
});
|
||||
let creditCards = await getCreditCards();
|
||||
|
||||
|
@ -100,20 +100,16 @@ add_task(async function test_saveCreditCardWithMaxYear() {
|
|||
add_task(async function test_editCreditCard() {
|
||||
let creditCards = await getCreditCards();
|
||||
is(creditCards.length, 1, "only one credit card is in storage");
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL, null, null, creditCards[0]);
|
||||
win.addEventListener("FormReady", () => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {}, win);
|
||||
EventUtils.synthesizeKey("test", {}, win);
|
||||
win.document.querySelector("#save").click();
|
||||
}, {once: true});
|
||||
});
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL, null, null, creditCards[0]);
|
||||
await waitForFocusAndFormReady(win);
|
||||
let unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {}, win);
|
||||
EventUtils.synthesizeKey("test", {}, win);
|
||||
win.document.querySelector("#save").click();
|
||||
await unloadPromise;
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
creditCards = await getCreditCards();
|
||||
|
||||
is(creditCards.length, 1, "only one credit card is in storage");
|
||||
|
@ -127,7 +123,7 @@ add_task(async function test_editCreditCard() {
|
|||
add_task(async function test_addInvalidCreditCard() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
win.addEventListener("load", () => {
|
||||
waitForFocus(() => {
|
||||
const unloadHandler = () => ok(false, "Edit credit card dialog shouldn't be closed");
|
||||
win.addEventListener("unload", unloadHandler);
|
||||
|
||||
|
@ -142,7 +138,7 @@ add_task(async function test_addInvalidCreditCard() {
|
|||
win.close();
|
||||
resolve();
|
||||
}, 500);
|
||||
}, {once: true});
|
||||
}, win);
|
||||
});
|
||||
let creditCards = await getCreditCards();
|
||||
|
||||
|
|
|
@ -26,16 +26,12 @@ add_task(async function test_manageAddressesInitialState() {
|
|||
});
|
||||
|
||||
add_task(async function test_cancelManageAddressDialogWithESC() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(MANAGE_ADDRESSES_DIALOG_URL);
|
||||
win.addEventListener("FormReady", () => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Manage addresses dialog is closed with ESC key");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
}, {once: true});
|
||||
});
|
||||
let win = window.openDialog(MANAGE_ADDRESSES_DIALOG_URL);
|
||||
await waitForFocusAndFormReady(win);
|
||||
let unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
await unloadPromise;
|
||||
ok(true, "Manage addresses dialog is closed with ESC key");
|
||||
});
|
||||
|
||||
add_task(async function test_removingSingleAndMultipleAddresses() {
|
||||
|
@ -44,7 +40,7 @@ add_task(async function test_removingSingleAndMultipleAddresses() {
|
|||
await saveAddress(TEST_ADDRESS_3);
|
||||
|
||||
let win = window.openDialog(MANAGE_ADDRESSES_DIALOG_URL, null, DIALOG_SIZE);
|
||||
await BrowserTestUtils.waitForEvent(win, "FormReady");
|
||||
await waitForFocusAndFormReady(win);
|
||||
|
||||
let selRecords = win.document.querySelector(TEST_SELECTORS.selRecords);
|
||||
let btnRemove = win.document.querySelector(TEST_SELECTORS.btnRemove);
|
||||
|
@ -73,7 +69,7 @@ add_task(async function test_removingSingleAndMultipleAddresses() {
|
|||
|
||||
add_task(async function test_addressesDialogWatchesStorageChanges() {
|
||||
let win = window.openDialog(MANAGE_ADDRESSES_DIALOG_URL, null, DIALOG_SIZE);
|
||||
await BrowserTestUtils.waitForEvent(win, "FormReady");
|
||||
await waitForFocusAndFormReady(win);
|
||||
|
||||
let selRecords = win.document.querySelector(TEST_SELECTORS.selRecords);
|
||||
|
||||
|
|
|
@ -29,16 +29,12 @@ add_task(async function test_manageCreditCardsInitialState() {
|
|||
});
|
||||
|
||||
add_task(async function test_cancelManageCreditCardsDialogWithESC() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(MANAGE_CREDIT_CARDS_DIALOG_URL);
|
||||
win.addEventListener("FormReady", () => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Manage credit cards dialog is closed with ESC key");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
}, {once: true});
|
||||
});
|
||||
let win = window.openDialog(MANAGE_CREDIT_CARDS_DIALOG_URL);
|
||||
await waitForFocusAndFormReady(win);
|
||||
let unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
await unloadPromise;
|
||||
ok(true, "Manage credit cards dialog is closed with ESC key");
|
||||
});
|
||||
|
||||
add_task(async function test_removingSingleAndMultipleCreditCards() {
|
||||
|
@ -47,7 +43,7 @@ add_task(async function test_removingSingleAndMultipleCreditCards() {
|
|||
await saveCreditCard(TEST_CREDIT_CARD_3);
|
||||
|
||||
let win = window.openDialog(MANAGE_CREDIT_CARDS_DIALOG_URL, null, DIALOG_SIZE);
|
||||
await BrowserTestUtils.waitForEvent(win, "FormReady");
|
||||
await waitForFocusAndFormReady(win);
|
||||
|
||||
let selRecords = win.document.querySelector(TEST_SELECTORS.selRecords);
|
||||
let btnRemove = win.document.querySelector(TEST_SELECTORS.btnRemove);
|
||||
|
@ -79,7 +75,7 @@ add_task(async function test_removingSingleAndMultipleCreditCards() {
|
|||
|
||||
add_task(async function test_creditCardsDialogWatchesStorageChanges() {
|
||||
let win = window.openDialog(MANAGE_CREDIT_CARDS_DIALOG_URL, null, DIALOG_SIZE);
|
||||
await BrowserTestUtils.waitForEvent(win, "FormReady");
|
||||
await waitForFocusAndFormReady(win);
|
||||
|
||||
let selRecords = win.document.querySelector(TEST_SELECTORS.selRecords);
|
||||
|
||||
|
@ -99,7 +95,7 @@ add_task(async function test_showCreditCards() {
|
|||
await saveCreditCard(TEST_CREDIT_CARD_3);
|
||||
|
||||
let win = window.openDialog(MANAGE_CREDIT_CARDS_DIALOG_URL, null, DIALOG_SIZE);
|
||||
await BrowserTestUtils.waitForEvent(win, "FormReady");
|
||||
await waitForFocusAndFormReady(win);
|
||||
|
||||
let selRecords = win.document.querySelector(TEST_SELECTORS.selRecords);
|
||||
let btnShowHideCreditCards = win.document.querySelector(TEST_SELECTORS.btnShowHideCreditCards);
|
||||
|
@ -148,7 +144,7 @@ add_task(async function test_hasMasterPassword() {
|
|||
LoginTestUtils.masterPassword.enable();
|
||||
|
||||
let win = window.openDialog(MANAGE_CREDIT_CARDS_DIALOG_URL, null, DIALOG_SIZE);
|
||||
await BrowserTestUtils.waitForEvent(win, "FormReady");
|
||||
await waitForFocusAndFormReady(win);
|
||||
|
||||
let selRecords = win.document.querySelector(TEST_SELECTORS.selRecords);
|
||||
let btnRemove = win.document.querySelector(TEST_SELECTORS.btnRemove);
|
||||
|
|
|
@ -329,17 +329,19 @@ async function removeAllRecords() {
|
|||
}
|
||||
}
|
||||
|
||||
function testDialog(url, testFn, arg) {
|
||||
return new Promise(resolve => {
|
||||
let win = window.openDialog(url, null, null, arg);
|
||||
win.addEventListener("FormReady", () => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Dialog is closed");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
testFn(win);
|
||||
}, {once: true});
|
||||
});
|
||||
async function waitForFocusAndFormReady(win) {
|
||||
return Promise.all([
|
||||
new Promise(resolve => waitForFocus(resolve, win)),
|
||||
BrowserTestUtils.waitForEvent(win, "FormReady"),
|
||||
]);
|
||||
}
|
||||
|
||||
async function testDialog(url, testFn, arg) {
|
||||
let win = window.openDialog(url, null, null, arg);
|
||||
await waitForFocusAndFormReady(win);
|
||||
let unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
|
||||
testFn(win);
|
||||
return unloadPromise;
|
||||
}
|
||||
|
||||
registerCleanupFunction(removeAllRecords);
|
||||
|
|
Загрузка…
Ссылка в новой задаче