Bug 1440041 - Update the selected shipping option on PaymentRequest when updating the list of options.
MozReview-Commit-ID: 8tUbVJomKcZ
--- 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);