Bug 1463538 - Fix previously uncaught errors in PaymentReqest UI tests. r=jaws
☠☠ backed out by 33e3e8ed47f9 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 23 Jul 2018 11:38:47 -0700
changeset 427955 1c945ede0071fac3f11a6cddd48cb68517a1132a
parent 427954 8ccd9f4b230d603421de687e8d58844071470b15
child 427956 3b0192c401cf32dbbf25d36f2bbbec0e0b392562
push id34322
push userrgurzau@mozilla.com
push dateTue, 24 Jul 2018 15:47:07 +0000
treeherdermozilla-central@db9d47b49936 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1463538
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1463538 - Fix previously uncaught errors in PaymentReqest UI tests. r=jaws MozReview-Commit-ID: JUu3ljLLDLO
browser/components/payments/res/containers/address-picker.js
browser/components/payments/test/browser/browser_address_edit.js
browser/components/payments/test/browser/browser_change_shipping.js
browser/components/payments/test/browser/browser_payments_onboarding_wizard.js
browser/components/payments/test/mochitest/payments_common.js
browser/components/payments/test/mochitest/test_payer_address_picker.html
--- a/browser/components/payments/res/containers/address-picker.js
+++ b/browser/components/payments/res/containers/address-picker.js
@@ -105,17 +105,17 @@ export default class AddressPicker exten
       this.dropdown.popupBox.appendChild(option);
     }
 
     // Update selectedness after the options are updated
     let selectedAddressGUID = state[this.selectedStateKey];
     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`);
     }
   }
 
   get selectedStateKey() {
     return this.getAttribute("selected-state-key");
   }
 
--- a/browser/components/payments/test/browser/browser_address_edit.js
+++ b/browser/components/payments/test/browser/browser_address_edit.js
@@ -4,16 +4,21 @@
 
 async function setup() {
   await setupFormAutofillStorage();
   await cleanupFormAutofillStorage();
   // add an address and card to avoid the FTU sequence
   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;
 }
 
 /*
  * Test that we can correctly add an address and elect for it to be saved or temporary
  */
 add_task(async function test_add_link() {
   let prefilledGuids = await setup();
--- a/browser/components/payments/test/browser/browser_change_shipping.js
+++ b/browser/components/payments/test/browser/browser_change_shipping.js
@@ -1,13 +1,18 @@
 "use strict";
 
 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() {
   await setup();
   await BrowserTestUtils.withNewTab({
     gBrowser,
     url: BLANK_PAGE_URL,
   }, async browser => {
--- a/browser/components/payments/test/browser/browser_payments_onboarding_wizard.js
+++ b/browser/components/payments/test/browser/browser_payments_onboarding_wizard.js
@@ -77,17 +77,17 @@ add_task(async function test_onboarding_
       let cardSaveButton = content.document.querySelector("basic-card-form .save-button");
       ok(content.isVisible(cardSaveButton), "Basic card page is rendered");
 
       let basicCardTitle = content.document.querySelector("basic-card-form h2");
       ok(content.isVisible(basicCardTitle), "Basic card page title is visible");
       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");
 
       for (let [key, val] of Object.entries(PTU.BasicCards.JohnDoe)) {
         let field = content.document.getElementById(key);
         field.value = val;
         ok(!field.disabled, `Field #${key} shouldn't be disabled`);
@@ -347,17 +347,17 @@ add_task(async function test_onboarding_
         return state.page.id == "basic-card-page";
       // eslint-disable-next-line max-len
       }, "Basic card page is shown after the billing address page during onboarding if requestShipping is turned off");
 
       let cardSaveButton = content.document.querySelector("basic-card-form .save-button");
       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");
 
       for (let [key, val] of Object.entries(PTU.BasicCards.JohnDoe)) {
         let field = content.document.getElementById(key);
         field.value = val;
         ok(!field.disabled, `Field #${key} shouldn't be disabled`);
--- a/browser/components/payments/test/mochitest/payments_common.js
+++ b/browser/components/payments/test/mochitest/payments_common.js
@@ -1,12 +1,12 @@
 "use strict";
 
 /* exported asyncElementRendered, promiseStateChange, promiseContentToChromeMessage, deepClone,
-   PTU */
+   PTU, registerConsoleFilter */
 
 const PTU = SpecialPowers.Cu.import("resource://testing-common/PaymentTestUtils.jsm", {})
                             .PaymentTestUtils;
 
 /**
  * A helper to await on while waiting for an asynchronous rendering of a Custom
  * Element.
  * @returns {Promise}
@@ -42,23 +42,39 @@ function promiseContentToChromeMessage(m
     });
   });
 }
 
 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;
   }
   if (msg.category == "CSP_CSPViolationWithURI" && msg.errorMessage.includes("at inline")) {
     // 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();
 });
--- a/browser/components/payments/test/mochitest/test_payer_address_picker.html
+++ b/browser/components/payments/test/mochitest/test_payer_address_picker.html
@@ -113,16 +113,20 @@ let DUPED_ADDRESSES = {
   },
 };
 
 let elPicker;
 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);
 
   let displayEl = document.getElementById("display");
   // Import the templates from the real shipping dialog to avoid duplication.
   for (let template of templateFrame.contentDocument.querySelectorAll("template")) {
     let imported = document.importNode(template, true);
     displayEl.appendChild(imported);