Bug 1480880 - Fix exposing of payment defaults prefs object. r=MattN
authorSam Foster <sfoster@mozilla.com>
Fri, 03 Aug 2018 11:51:10 -0700
changeset 485894 554e0fbeec46e2c89d4006f6f7a1cffe02c98852
parent 485893 65a6a118cb1a7bbe4c2af3ee41e89eb6704f48bc
child 485895 f90c0cecba1973e07e5bed1d8c9faf5a48a66b16
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1480880
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 1480880 - Fix exposing of payment defaults prefs object. r=MattN MozReview-Commit-ID: DRSiGjk6wyS
browser/components/payments/content/paymentDialogFrameScript.js
browser/components/payments/res/containers/address-form.js
browser/components/payments/res/containers/basic-card-form.js
--- a/browser/components/payments/content/paymentDialogFrameScript.js
+++ b/browser/components/payments/content/paymentDialogFrameScript.js
@@ -91,17 +91,17 @@ let PaymentFrameScript = {
 
       getDefaultPreferences() {
         let prefValues = Cu.cloneInto({
           saveCreditCardDefaultChecked:
             Services.prefs.getBoolPref(SAVE_CREDITCARD_DEFAULT_PREF, false),
           saveAddressDefaultChecked:
             Services.prefs.getBoolPref(SAVE_ADDRESS_DEFAULT_PREF, false),
         }, waivedContent);
-        return prefValues;
+        return Cu.cloneInto(prefValues, waivedContent);
       },
     };
     waivedContent.PaymentDialogUtils = Cu.cloneInto(PaymentDialogUtils, waivedContent, {
       cloneFunctions: true,
     });
   },
 
   sendToChrome({detail}) {
--- a/browser/components/payments/res/containers/address-form.js
+++ b/browser/components/payments/res/containers/address-form.js
@@ -138,21 +138,25 @@ export default class AddressForm extends
     if (editing) {
       record = addresses[addressPage.guid];
       if (!record) {
         throw new Error("Trying to edit a non-existing address: " + addressPage.guid);
       }
       // When editing an existing record, prevent changes to persistence
       this.persistCheckbox.hidden = true;
     } else {
-      let defaults = PaymentDialogUtils.getDefaultPreferences();
+      let {saveAddressDefaultChecked} = PaymentDialogUtils.getDefaultPreferences();
+      if (typeof saveAddressDefaultChecked != "boolean") {
+        throw new Error(`Unexpected non-boolean value for saveAddressDefaultChecked from
+          PaymentDialogUtils.getDefaultPreferences(): ${typeof saveAddressDefaultChecked}`);
+      }
       // Adding a new record: default persistence to the pref value when in a not-private session
       this.persistCheckbox.hidden = false;
       this.persistCheckbox.checked = state.isPrivate ? false :
-                                                       defaults.saveAddressDefaultChecked;
+                                                       saveAddressDefaultChecked;
     }
 
     this.formHandler.loadRecord(record);
 
     // Add validation to some address fields
     this.updateRequiredState();
 
     let shippingAddressErrors = request.paymentDetails.shippingAddressErrors;
--- a/browser/components/payments/res/containers/basic-card-form.js
+++ b/browser/components/payments/res/containers/basic-card-form.js
@@ -153,25 +153,29 @@ export default class BasicCardForm exten
     } else {
       this.pageTitleHeading.textContent = this.dataset.addBasicCardTitle;
       // Use a currently selected shipping address as the default billing address
       record.billingAddressGUID = basicCardPage.billingAddressGUID;
       if (!record.billingAddressGUID && selectedShippingAddress) {
         record.billingAddressGUID = selectedShippingAddress;
       }
 
-      let defaults = PaymentDialogUtils.getDefaultPreferences();
+      let {saveCreditCardDefaultChecked} = PaymentDialogUtils.getDefaultPreferences();
+      if (typeof saveCreditCardDefaultChecked != "boolean") {
+        throw new Error(`Unexpected non-boolean value for saveCreditCardDefaultChecked from
+          PaymentDialogUtils.getDefaultPreferences(): ${typeof saveCreditCardDefaultChecked}`);
+      }
       // Adding a new record: default persistence to pref value when in a not-private session
       this.persistCheckbox.hidden = false;
       if (basicCardPage.hasOwnProperty("persistCheckboxValue")) {
         // returning to this page, use previous checked state
         this.persistCheckbox.checked = basicCardPage.persistCheckboxValue;
       } else {
         this.persistCheckbox.checked = state.isPrivate ? false :
-                                                         defaults.saveCreditCardDefaultChecked;
+                                                         saveCreditCardDefaultChecked;
       }
     }
 
     this.formHandler.loadRecord(record, addresses, basicCardPage.preserveFieldValues);
 
     this.form.querySelector(".billingAddressRow").hidden = false;
 
     let billingAddressSelect = this.form.querySelector("#billingAddressGUID");