Bug 1463538 - Fix previously uncaught errors in PaymentReqest UI tests. r=jaws

MozReview-Commit-ID: JUu3ljLLDLO

--HG--
extra : rebase_source : 421c9b1edc1d20a9498871e09c2e4437450609a1
This commit is contained in:
Matthew Noorenberghe 2018-07-23 11:38:47 -07:00
Родитель f0ffcbc51a
Коммит a24d524daf
6 изменённых файлов: 36 добавлений и 6 удалений

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

@ -110,7 +110,7 @@ export default class AddressPicker extends RichPicker {
this.dropdown.value = selectedAddressGUID;
if (selectedAddressGUID && selectedAddressGUID !== this.dropdown.value) {
throw new Error(`${this.selectedStateKey} option ${selectedAddressGUID}` +
throw new Error(`${this.selectedStateKey} option ${selectedAddressGUID} ` +
`does not exist in the address picker`);
}
}

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

@ -9,6 +9,11 @@ async function setup() {
let prefilledGuids = await addSampleAddressesAndBasicCard(
[PTU.Addresses.TimBL], [PTU.BasicCards.JohnDoe]);
info("associating the card with the billing address");
formAutofillStorage.creditCards.update(prefilledGuids.card1GUID, {
billingAddressGUID: prefilledGuids.address1GUID,
}, true);
return prefilledGuids;
}

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

@ -2,7 +2,12 @@
async function setup() {
await setupFormAutofillStorage();
await addSampleAddressesAndBasicCard();
let prefilledGuids = await addSampleAddressesAndBasicCard();
info("associating the card with the billing address");
formAutofillStorage.creditCards.update(prefilledGuids.card1GUID, {
billingAddressGUID: prefilledGuids.address1GUID,
}, true);
}
add_task(async function test_change_shipping() {

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

@ -82,7 +82,7 @@ add_task(async function test_onboarding_wizard_without_saved_addresses_and_saved
is(basicCardTitle.textContent, "Add Credit Card", "Basic card page title is correctly shown");
info("Check if the correct billing address is selected in the basic card page");
PTU.DialogContentUtils.waitForState((state) => {
PTU.DialogContentUtils.waitForState(content, (state) => {
let billingAddressSelect = content.document.querySelector("#billingAddressGUID");
return state.selectedShippingAddress == billingAddressSelect.value;
}, "Shipping address is selected as the billing address");
@ -352,7 +352,7 @@ add_task(async function test_onboarding_wizard_with_requestShipping_turned_off()
ok(content.isVisible(cardSaveButton), "Basic card page is rendered");
info("Check if the correct billing address is selected in the basic card page");
PTU.DialogContentUtils.waitForState((state) => {
PTU.DialogContentUtils.waitForState(content, (state) => {
let billingAddressSelect = content.document.querySelector("#billingAddressGUID");
return state["basic-card-page"].billingAddressGUID == billingAddressSelect.value;
}, "Billing Address is correctly shown");

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

@ -1,7 +1,7 @@
"use strict";
/* exported asyncElementRendered, promiseStateChange, promiseContentToChromeMessage, deepClone,
PTU */
PTU, registerConsoleFilter */
const PTU = SpecialPowers.Cu.import("resource://testing-common/PaymentTestUtils.jsm", {})
.PaymentTestUtils;
@ -47,9 +47,18 @@ function deepClone(obj) {
return JSON.parse(JSON.stringify(obj));
}
/**
* If filterFunction is a function which returns true given a console message
* then the test won't fail from that message.
*/
let filterFunction = null;
function registerConsoleFilter(filterFn) {
filterFunction = filterFn;
}
// Listen for errors to fail tests
SpecialPowers.registerConsoleListener(function onConsoleMessage(msg) {
if (msg.isWarning || !msg.errorMessage) {
if (msg.isWarning || !msg.errorMessage || msg.errorMessage == "paymentRequest.xhtml:") {
// Ignore warnings and non-errors.
return;
}
@ -57,8 +66,15 @@ SpecialPowers.registerConsoleListener(function onConsoleMessage(msg) {
// Ignore unknown CSP error.
return;
}
if (msg.message == "SENTINEL") {
filterFunction = null;
}
if (filterFunction && filterFunction(msg)) {
return;
}
ok(false, msg.message || msg.errorMessage);
});
SimpleTest.registerCleanupFunction(function cleanup() {
SpecialPowers.postConsoleSentinel();
});

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

@ -118,6 +118,10 @@ let elDialog;
let initialState;
add_task(async function setup_once() {
registerConsoleFilter(function consoleFilter(msg) {
return msg.errorMessage.includes("selectedPayerAddress option a9e830667189 does not exist");
});
let templateFrame = document.getElementById("templateFrame");
await SimpleTest.promiseFocus(templateFrame.contentWindow);