Bug 1427510 - Use current year as expiration year in credit card test case to fix perma failure. r=lchang

MozReview-Commit-ID: IuDCc6UDfay

--HG--
extra : rebase_source : b6bfa0a2ebe55e731ce135757a18440d60a84682
This commit is contained in:
Scott Wu 2018-01-09 17:33:04 +08:00
Родитель 124c284658
Коммит a9888b57e5
4 изменённых файлов: 42 добавлений и 8 удалений

Просмотреть файл

@ -15,7 +15,6 @@ support-files =
[browser_dropdown_layout.js]
[browser_editAddressDialog.js]
[browser_editCreditCardDialog.js]
skip-if = true # Bug 1427510
[browser_first_time_use_doorhanger.js]
[browser_insecure_form.js]
[browser_manageAddressesDialog.js]

Просмотреть файл

@ -137,7 +137,7 @@ add_task(async function test_submit_changed_subset_creditCard_form() {
form.querySelector("#cc-number").setUserInput("1234567812345678");
form.querySelector("#cc-exp-month").setUserInput("4");
form.querySelector("#cc-exp-year").setUserInput("2017");
form.querySelector("#cc-exp-year").setUserInput(new Date().getFullYear());
// Wait 1000ms before submission to make sure the input value applied
await new Promise(resolve => setTimeout(resolve, 1000));
form.querySelector("input[type=submit]").click();
@ -175,7 +175,7 @@ add_task(async function test_submit_duplicate_creditCard_form() {
name.setUserInput("John Doe");
form.querySelector("#cc-number").setUserInput("1234567812345678");
form.querySelector("#cc-exp-month").setUserInput("4");
form.querySelector("#cc-exp-year").setUserInput("2017");
form.querySelector("#cc-exp-year").setUserInput(new Date().getFullYear());
// Wait 1000ms before submission to make sure the input value applied
await new Promise(resolve => setTimeout(resolve, 1000));
@ -212,7 +212,7 @@ add_task(async function test_submit_unnormailzed_creditCard_form() {
form.querySelector("#cc-number").setUserInput("1234567812345678");
form.querySelector("#cc-exp-month").setUserInput("4");
// Set unnormalized year
form.querySelector("#cc-exp-year").setUserInput("17");
form.querySelector("#cc-exp-year").setUserInput(new Date().getFullYear().toString().substr(2, 2));
// Wait 1000ms before submission to make sure the input value applied
await new Promise(resolve => setTimeout(resolve, 1000));
@ -226,7 +226,7 @@ add_task(async function test_submit_unnormailzed_creditCard_form() {
creditCards = await getCreditCards();
is(creditCards.length, 1, "Still 1 credit card in storage");
is(creditCards[0]["cc-exp-year"], "2017", "Verify the expiry year field");
is(creditCards[0]["cc-exp-year"], new Date().getFullYear(), "Verify the expiry year field");
await removeAllRecords();
});

Просмотреть файл

@ -62,6 +62,41 @@ add_task(async function test_saveCreditCard() {
ok(creditCards[0]["cc-number-encrypted"], "cc-number-encrypted exists");
});
add_task(async function test_saveCreditCardWithMaxYear() {
await new Promise(resolve => {
let win = window.openDialog(EDIT_CREDIT_CARD_DIALOG_URL);
win.addEventListener("load", () => {
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);
}, {once: true});
});
let creditCards = await getCreditCards();
is(creditCards.length, 2, "Two credit card is in storage");
for (let [fieldName, fieldValue] of Object.entries(TEST_CREDIT_CARD_2)) {
if (fieldName === "cc-number") {
fieldValue = "*".repeat(fieldValue.length - 4) + fieldValue.substr(-4);
}
is(creditCards[1][fieldName], fieldValue, "check " + fieldName);
}
ok(creditCards[1]["cc-number-encrypted"], "cc-number-encrypted exists");
await removeCreditCards([creditCards[1].guid]);
});
add_task(async function test_editCreditCard() {
let creditCards = await getCreditCards();
is(creditCards.length, 1, "only one credit card is in storage");
@ -92,7 +127,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("FormReady", () => {
win.addEventListener("load", () => {
const unloadHandler = () => ok(false, "Edit credit card dialog shouldn't be closed");
win.addEventListener("unload", unloadHandler);

Просмотреть файл

@ -100,14 +100,14 @@ const TEST_CREDIT_CARD_1 = {
"cc-name": "John Doe",
"cc-number": "1234567812345678",
"cc-exp-month": 4,
"cc-exp-year": 2017,
"cc-exp-year": new Date().getFullYear(),
};
const TEST_CREDIT_CARD_2 = {
"cc-name": "Timothy Berners-Lee",
"cc-number": "1111222233334444",
"cc-exp-month": 12,
"cc-exp-year": 2022,
"cc-exp-year": new Date().getFullYear() + 10,
};
const TEST_CREDIT_CARD_3 = {