Bug 1440041 - Update the selected shipping option on PaymentRequest when updating the list of options. draft
authorHenri Sivonen <hsivonen@hsivonen.fi>
Tue, 13 Mar 2018 16:01:11 +0200
changeset 766859 4e770cd62667
parent 766750 2bf72d97efc1
push id102420
push userbmo:hsivonen@hsivonen.fi
push dateTue, 13 Mar 2018 14:02:41 +0000
bugs1440041
milestone60.0a1
Bug 1440041 - Update the selected shipping option on PaymentRequest when updating the list of options. MozReview-Commit-ID: 8tUbVJomKcZ
dom/payments/PaymentRequestManager.cpp
--- a/dom/payments/PaymentRequestManager.cpp
+++ b/dom/payments/PaymentRequestManager.cpp
@@ -553,21 +553,23 @@ PaymentRequestManager::UpdatePayment(JSC
                                      bool aRequestShipping)
 {
   NS_ENSURE_ARG_POINTER(aCx);
   RefPtr<PaymentRequest> request = GetPaymentRequestById(aRequestId);
   if (!request) {
     return NS_ERROR_UNEXPECTED;
   }
 
-  // [TODO] Process details.shippingOptions if presented.
-  //        1) Check if there are duplicate IDs in details.shippingOptions,
-  //           if so, reset details.shippingOptions to an empty sequence.
-  //        2) Set request's selectedShippingOption to the ID of last selected
-  //           option.
+  // [TODO] Reset details.shippingOptions to an empty sequence if
+  //        aRequestShipping is false or PaymentRequest::IsValidDetailsBase
+  //        found duplicate ids.
+
+  nsAutoString selectedShippingOption;
+  GetSelectedShippingOption(aDetails, selectedShippingOption);
+  request.SetShippingOption(selectedShippingOption);
 
   IPCPaymentDetails details;
   nsresult rv = ConvertDetailsUpdate(aCx, aDetails, details, aRequestShipping);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsAutoString requestId(aRequestId);