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()
This commit is contained in:
Eden Chuang 2018-08-22 03:10:45 +02:00
Родитель 6fddec41b3
Коммит a29e2c4da2
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -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<PaymentRequestManager> 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<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
MOZ_ASSERT(manager);