зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1432952 - Use the testDialog helper in browser_editCreditCardDialog.js. r=jaws
MozReview-Commit-ID: 9tquQ0C7D93 --HG-- extra : rebase_source : e28eacb8c2c5d1e58c7e93ef71bd50226dfa08fd
This commit is contained in:
Родитель
c9245ebac5
Коммит
0a88f6179d
|
@ -3,52 +3,31 @@
|
|||
"use strict";
|
||||
|
||||
add_task(async function test_cancelEditCreditCardDialog() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
win.document.querySelector("#cancel").click();
|
||||
}, win);
|
||||
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
|
||||
win.document.querySelector("#cancel").click();
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_cancelEditCreditCardDialogWithESC() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed with ESC key");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
}, win);
|
||||
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_saveCreditCard() {
|
||||
await new Promise(resolve => {
|
||||
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-number"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-name"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("0" + TEST_CREDIT_CARD_1["cc-exp-month"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-exp-year"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
info("saving credit card");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
}, win);
|
||||
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-number"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-name"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("0" + TEST_CREDIT_CARD_1["cc-exp-month"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-exp-year"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
info("saving credit card");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
});
|
||||
let creditCards = await getCreditCards();
|
||||
|
||||
|
@ -63,26 +42,19 @@ 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);
|
||||
waitForFocus(() => {
|
||||
win.addEventListener("unload", () => {
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
resolve();
|
||||
}, {once: true});
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-number"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-name"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-exp-month"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-exp-year"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
info("saving credit card");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
}, win);
|
||||
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-number"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-name"], {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-exp-month"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey(TEST_CREDIT_CARD_2["cc-exp-year"].toString(), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
info("saving credit card");
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
});
|
||||
let creditCards = await getCreditCards();
|
||||
|
||||
|
@ -100,15 +72,13 @@ 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");
|
||||
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;
|
||||
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {}, win);
|
||||
EventUtils.synthesizeKey("test", {}, win);
|
||||
win.document.querySelector("#save").click();
|
||||
}, creditCards[0]);
|
||||
ok(true, "Edit credit card dialog is closed");
|
||||
creditCards = await getCreditCards();
|
||||
|
||||
|
@ -121,24 +91,20 @@ 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);
|
||||
waitForFocus(() => {
|
||||
const unloadHandler = () => ok(false, "Edit credit card dialog shouldn't be closed");
|
||||
win.addEventListener("unload", unloadHandler);
|
||||
await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
|
||||
const unloadHandler = () => ok(false, "Edit credit card dialog shouldn't be closed");
|
||||
win.addEventListener("unload", unloadHandler);
|
||||
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("test", {}, win);
|
||||
EventUtils.synthesizeMouseAtCenter(win.document.querySelector("#save"), {}, win);
|
||||
EventUtils.synthesizeKey("VK_TAB", {}, win);
|
||||
EventUtils.synthesizeKey("test", {}, win);
|
||||
EventUtils.synthesizeMouseAtCenter(win.document.querySelector("#save"), {}, win);
|
||||
|
||||
is(win.document.querySelector("form").checkValidity(), false, "cc-number is invalid");
|
||||
SimpleTest.requestFlakyTimeout("Ensure the window remains open after save attempt");
|
||||
setTimeout(() => {
|
||||
win.removeEventListener("unload", unloadHandler);
|
||||
win.close();
|
||||
resolve();
|
||||
}, 500);
|
||||
}, win);
|
||||
is(win.document.querySelector("form").checkValidity(), false, "cc-number is invalid");
|
||||
SimpleTest.requestFlakyTimeout("Ensure the window remains open after save attempt");
|
||||
setTimeout(() => {
|
||||
win.removeEventListener("unload", unloadHandler);
|
||||
win.close();
|
||||
}, 500);
|
||||
});
|
||||
let creditCards = await getCreditCards();
|
||||
|
||||
|
|
|
@ -338,7 +338,7 @@ async function waitForFocusAndFormReady(win) {
|
|||
]);
|
||||
}
|
||||
|
||||
async function testDialog(url, testFn, arg) {
|
||||
async function testDialog(url, testFn, arg = undefined) {
|
||||
let win = window.openDialog(url, null, "width=600,height=600", arg);
|
||||
await waitForFocusAndFormReady(win);
|
||||
let unloadPromise = BrowserTestUtils.waitForEvent(win, "unload");
|
||||
|
|
Загрузка…
Ссылка в новой задаче