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

MozReview-Commit-ID: JUu3ljLLDLO

--HG--
extra : rebase_source : c1f72bc856bba0760b1ee427327ef6e4c7ec806a
This commit is contained in:
Matthew Noorenberghe 2018-07-23 11:38:47 -07:00
parent 8be80047e1
commit 1671d3642c
6 changed files with 36 additions and 6 deletions

View File

@ -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`);
}
}

View File

@ -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;
}

View File

@ -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() {

View File

@ -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");

View File

@ -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();
});

View File

@ -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);