Bug 1429205 - Add a sendMessageToContent helper for paymentDialogWrapper. r=jaws
☠☠ backed out by c6a22782eeb4 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 20 Feb 2018 15:56:33 -0800
changeset 459940 ced4c7041d8e6edf21709e736e867fa30bc07e96
parent 459939 197404819c146857fbf1b5525a9e319a94ceebc0
child 459941 3f8c4cb7982f3b8ef0915b4e274c4135ffcac6b8
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1429205
milestone60.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 1429205 - Add a sendMessageToContent helper for paymentDialogWrapper. r=jaws MozReview-Commit-ID: FgeQaOR5yno
toolkit/components/payments/content/paymentDialogWrapper.js
--- a/toolkit/components/payments/content/paymentDialogWrapper.js
+++ b/toolkit/components/payments/content/paymentDialogWrapper.js
@@ -232,22 +232,26 @@ var paymentDialogWrapper = {
       // Filter out the encrypted card number since the dialog content is
       // considered untrusted and runs in a content process.
       delete card["cc-number-encrypted"];
     }
     return savedBasicCards;
   },
 
   onAutofillStorageChange() {
+    this.sendMessageToContent("updateState", {
+      savedAddresses: this.fetchSavedAddresses(),
+      savedBasicCards: this.fetchSavedPaymentCards(),
+    });
+  },
+
+  sendMessageToContent(messageType, data = {}) {
     this.mm.sendAsyncMessage("paymentChromeToContent", {
-      messageType: "updateState",
-      data: {
-        savedAddresses: this.fetchSavedAddresses(),
-        savedBasicCards: this.fetchSavedPaymentCards(),
-      },
+      data,
+      messageType,
     });
   },
 
   /**
    * Recursively convert and filter input to the subset of data types supported by JSON
    *
    * @param {*} value - any type of input to serialize
    * @param {string?} name - name or key associated with this input.
@@ -320,24 +324,20 @@ var paymentDialogWrapper = {
         obj[key] = result;
       }
     }
     return obj;
   },
 
   initializeFrame() {
     let requestSerialized = this._serializeRequest(this.request);
-
-    this.mm.sendAsyncMessage("paymentChromeToContent", {
-      messageType: "showPaymentRequest",
-      data: {
-        request: requestSerialized,
-        savedAddresses: this.fetchSavedAddresses(),
-        savedBasicCards: this.fetchSavedPaymentCards(),
-      },
+    this.sendMessageToContent("showPaymentRequest", {
+      request: requestSerialized,
+      savedAddresses: this.fetchSavedAddresses(),
+      savedBasicCards: this.fetchSavedPaymentCards(),
     });
 
     Services.obs.addObserver(this, "formautofill-storage-changed", true);
   },
 
   debugFrame() {
     // To avoid self-XSS-type attacks, ensure that Browser Chrome debugging is enabled.
     if (!Services.prefs.getBoolPref("devtools.chrome.enabled", false)) {