From a29e2c4da2f67a0a0219c7c604c626a74d5663b8 Mon Sep 17 00:00:00 2001 From: Eden Chuang Date: Wed, 22 Aug 2018 03:10:45 +0200 Subject: [PATCH] Bug 1483470 - Handling PaymentRequestUpdateEvent::updateWith() to a responed PaymentRequest. r=baku 1. Checking if the PaymentRequest::mState equals to eInteractive when calling PaymentRequest::UpdatePayment() and PaymentRequest::AbortUpdate. 2. Removing the non-suitable MOZ_ASSERT in PaymentRequest::RespondShowPayment() --- dom/payments/PaymentRequest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dom/payments/PaymentRequest.cpp b/dom/payments/PaymentRequest.cpp index b28389dc5ed3..84ef129c929a 100644 --- a/dom/payments/PaymentRequest.cpp +++ b/dom/payments/PaymentRequest.cpp @@ -746,7 +746,7 @@ void PaymentRequest::RejectShowPayment(nsresult aRejectReason) { MOZ_ASSERT(mAcceptPromise); - MOZ_ASSERT(ReadyForUpdate()); + MOZ_ASSERT(mState == eInteractive); mAcceptPromise->MaybeReject(aRejectReason); mState = eClosed; @@ -762,7 +762,6 @@ PaymentRequest::RespondShowPayment(const nsAString& aMethodName, nsresult aRv) { MOZ_ASSERT(mAcceptPromise); - MOZ_ASSERT(ReadyForUpdate()); MOZ_ASSERT(mState == eInteractive); if (NS_FAILED(aRv)) { @@ -866,6 +865,9 @@ PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetai bool aDeferredShow) { NS_ENSURE_ARG_POINTER(aCx); + if (mState != eInteractive) { + return NS_ERROR_DOM_INVALID_STATE_ERR; + } RefPtr manager = PaymentRequestManager::GetSingleton(); if (NS_WARN_IF(!manager)) { return NS_ERROR_FAILURE; @@ -883,6 +885,9 @@ PaymentRequest::AbortUpdate(nsresult aRv, bool aDeferredShow) { MOZ_ASSERT(NS_FAILED(aRv)); + if (mState != eInteractive) { + return; + } // Close down any remaining user interface. RefPtr manager = PaymentRequestManager::GetSingleton(); MOZ_ASSERT(manager);