зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1731763 - Always null-check on ParymentRequest::mAcceptPromise and PaymentResponse::mRetryPromise. r=jstutte
Since PaymentRequest::mAcceptPromise and PaymentResponse::mRetryPromise can be nulled in PaymentRequest::NotifyOwnerDocumentActivityChanged(), always null-check on these promise when calling RespondShowPayment() and RespondRetry(). Differential Revision: https://phabricator.services.mozilla.com/D127110
This commit is contained in:
Родитель
3122576765
Коммит
4e9aade4a5
|
@ -790,7 +790,6 @@ void PaymentRequest::RespondShowPayment(const nsAString& aMethodName,
|
|||
const nsAString& aPayerEmail,
|
||||
const nsAString& aPayerPhone,
|
||||
ErrorResult&& aResult) {
|
||||
MOZ_ASSERT(mAcceptPromise || mResponse);
|
||||
MOZ_ASSERT(mState == eInteractive);
|
||||
|
||||
if (aResult.Failed()) {
|
||||
|
@ -805,12 +804,17 @@ void PaymentRequest::RespondShowPayment(const nsAString& aMethodName,
|
|||
if (mResponse) {
|
||||
mResponse->RespondRetry(aMethodName, mShippingOption, mShippingAddress,
|
||||
aDetails, aPayerName, aPayerEmail, aPayerPhone);
|
||||
} else {
|
||||
} else if (mAcceptPromise) {
|
||||
RefPtr<PaymentResponse> paymentResponse = new PaymentResponse(
|
||||
GetOwner(), this, mId, aMethodName, mShippingOption, mShippingAddress,
|
||||
aDetails, aPayerName, aPayerEmail, aPayerPhone);
|
||||
mResponse = paymentResponse;
|
||||
mAcceptPromise->MaybeResolve(paymentResponse);
|
||||
} else {
|
||||
// mAccpetPromise could be nulled through document activity changed. And
|
||||
// there is nothing to do here.
|
||||
mState = eClosed;
|
||||
return;
|
||||
}
|
||||
|
||||
mState = eClosed;
|
||||
|
|
|
@ -280,6 +280,10 @@ void PaymentResponse::RespondRetry(const nsAString& aMethodName,
|
|||
const nsAString& aPayerName,
|
||||
const nsAString& aPayerEmail,
|
||||
const nsAString& aPayerPhone) {
|
||||
// mRetryPromise could be nulled when document activity is changed.
|
||||
if (!mRetryPromise) {
|
||||
return;
|
||||
}
|
||||
mMethodName = aMethodName;
|
||||
mShippingOption = aShippingOption;
|
||||
mShippingAddress = aShippingAddress;
|
||||
|
|
Загрузка…
Ссылка в новой задаче