Backed out 2 changesets (bug 1494917) for bc failures in browser/components/payments/test/browser/browser_address_edit.js CLOSED TREE

Backed out changeset 1cdcc397c971 (bug 1494917)
Backed out changeset 14cfc544bea0 (bug 1494917)
This commit is contained in:
Margareta Eliza Balazs 2018-12-20 15:58:09 +02:00
parent beea267813
commit d2f4fd53c6
6 changed files with 44 additions and 118 deletions

View File

@ -353,14 +353,7 @@ AmbientLightEventWarning=Use of the ambient light sensor is deprecated.
IDBOpenDBOptions_StorageTypeWarning=The storage attribute in options passed to indexedDB.open is deprecated and will soon be removed. To get persistent storage, please use navigator.storage.persist() instead.
DOMQuadBoundsAttrWarning=DOMQuad.bounds is deprecated in favor of DOMQuad.getBounds()
UnsupportedEntryTypesIgnored=Ignoring unsupported entryTypes: %S.
# LOCALIZATION NOTE (PaymentRequestRetryWithEmptyErrors): Do not translate "PaymentRequest". The %S is the id of the PaymentRequest.
PaymentRequestRetryWithEmptyErrors=Retrying the PaymentRequest(%S) with empty error fields.
# LOCALIZATION NOTE (PaymentRequestRetryWithNonemptyPayerErrorName): Do not translate "PaymentRequest", "PayerErrorFields.name" and "PaymentOptions.requestPayerName". The %S is the id of the PaymentRequest
PaymentRequestRetryWithNonemptyPayerErrorName=Retrying the PaymentRequest(%S) with non-empty PayerErrorFields.name, but PaymentOptions.requestPayerName is false.
# LOCALIZATION NOTE (PaymentRequestRetryWithNonemptyPayerErrorEmail): Do not translate "PaymentRequest", "PayerErrorFields.email" and "PaymentOptions.requestPayerEmail". The %S is the id of the PaymentRequest
PaymentRequestRetryWithNonemptyPayerErrorEmail=Retrying the PaymentRequest(%S) with non-empty PayerErrorFields.email, but PaymentOptions.requestPayerEmail is false.
# LOCALIZATION NOTE (PaymentRequestRetryWithNonemptyPayerErrorPhone): Do not translate "PaymentRequest", "PayerErrorFields.phone" and "PaymentOptions.requestPayerPhone". The %S is the id of the PaymentRequest
PaymentRequestRetryWithNonemptyPayerErrorPhone=Retrying the PaymentRequest(%S) with non-empty PayerErrorFields.phone, but PaymentOptions.requestPayerPhone is false.
#LOCALIZATION NOTE(DeprecatedTestingInterfaceWarning): Do not translate this message. It's just testing only.
DeprecatedTestingInterfaceWarning=TestingDeprecatedInterface is a testing-only interface and this is its testing deprecation message.
#LOCALIZATION NOTE(DeprecatedTestingMethodWarning): Do not translate this message. It's just testing only.

View File

@ -417,10 +417,6 @@ PaymentDetails::GetError(nsAString& aError) {
NS_IMETHODIMP
PaymentDetails::GetShippingAddressErrors(JSContext* aCx,
JS::MutableHandleValue aErrors) {
aErrors.set(JS::NullValue());
if (mShippingAddressErrors.IsEmpty()) {
return NS_OK;
}
AddressErrors errors;
errors.Init(mShippingAddressErrors);
if (!ToJSValue(aCx, errors, aErrors)) {
@ -431,10 +427,6 @@ PaymentDetails::GetShippingAddressErrors(JSContext* aCx,
NS_IMETHODIMP
PaymentDetails::GetPayerErrors(JSContext* aCx, JS::MutableHandleValue aErrors) {
aErrors.set(JS::NullValue());
if (mPayerErrors.IsEmpty()) {
return NS_OK;
}
PayerErrors errors;
errors.Init(mPayerErrors);
if (!ToJSValue(aCx, errors, aErrors)) {
@ -446,8 +438,8 @@ PaymentDetails::GetPayerErrors(JSContext* aCx, JS::MutableHandleValue aErrors) {
NS_IMETHODIMP
PaymentDetails::GetPaymentMethodErrors(JSContext* aCx,
JS::MutableHandleValue aErrors) {
aErrors.set(JS::NullValue());
if (mPaymentMethodErrors.IsEmpty()) {
aErrors.set(JS::NullValue());
return NS_OK;
}
nsresult rv = DeserializeToJSValue(mPaymentMethodErrors, aCx, aErrors);

View File

@ -4,15 +4,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "BasicCardPayment.h"
#include "mozilla/StaticPrefs.h"
#include "mozilla/dom/PaymentResponse.h"
#include "mozilla/dom/BasicCardPaymentBinding.h"
#include "mozilla/dom/PaymentRequestUpdateEvent.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/StaticPrefs.h"
#include "nsContentUtils.h"
#include "BasicCardPayment.h"
#include "PaymentAddress.h"
#include "PaymentRequestUtils.h"
#include "mozilla/EventStateManager.h"
namespace mozilla {
namespace dom {
@ -257,12 +256,16 @@ already_AddRefed<Promise> PaymentResponse::Retry(
return promise.forget();
}
ValidatePaymentValidationErrors(aErrors);
nsresult rv = ValidatePaymentValidationErrors(aErrors);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(rv);
return promise.forget();
}
// Depending on the PMI, try to do IDL type conversion
// (e.g., basic-card expects at BasicCardErrors dictionary)
nsAutoString errorMsg;
nsresult rv = ConvertPaymentMethodErrors(aCx, aErrors, errorMsg);
rv = ConvertPaymentMethodErrors(aCx, aErrors, errorMsg);
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_ASSERT(!errorMsg.IsEmpty());
ErrorResult error;
@ -334,119 +337,78 @@ nsresult PaymentResponse::ConvertPaymentMethodErrors(
return NS_OK;
}
void PaymentResponse::ValidatePaymentValidationErrors(
nsresult PaymentResponse::ValidatePaymentValidationErrors(
const PaymentValidationErrors& aErrors) {
// Should not be empty errors
// check PaymentValidationErrors.error
if (aErrors.mError.WasPassed() && !aErrors.mError.Value().IsEmpty()) {
return;
return NS_OK;
}
PaymentOptions options;
mRequest->GetOptions(options);
nsIDocument* doc = GetOwner()->GetExtantDoc();
// check PaymentValidationErrors.payer
if (aErrors.mPayer.WasPassed()) {
PayerErrors payerErrors(aErrors.mPayer.Value());
if (payerErrors.mName.WasPassed() && !payerErrors.mName.Value().IsEmpty()) {
if (!options.mRequestPayerName && doc) {
const char16_t* params[] = { mRequestId.get() };
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM::Web Payments"),
doc,
nsContentUtils::eDOM_PROPERTIES,
"PaymentRequestRetryWithNonemptyPayerErrorName",
params,
1);
}
return;
return NS_OK;
}
if (payerErrors.mEmail.WasPassed() &&
!payerErrors.mEmail.Value().IsEmpty()) {
if (!options.mRequestPayerEmail && doc) {
const char16_t* params[] = { mRequestId.get() };
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM::Web Payments"),
doc,
nsContentUtils::eDOM_PROPERTIES,
"PaymentRequestRetryWithNonemptyPayerErrorEmail",
params,
1);
}
return;
return NS_OK;
}
if (payerErrors.mPhone.WasPassed() &&
!payerErrors.mPhone.Value().IsEmpty()) {
if (!options.mRequestPayerPhone && doc) {
const char16_t* params[] = { mRequestId.get() };
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM::Web Payments"),
doc,
nsContentUtils::eDOM_PROPERTIES,
"PaymentRequestRetryWithNonemptyPayerErrorPhone",
params,
1);
}
return;
return NS_OK;
}
}
// check PaymentValidationErrors.paymentMethod
if (aErrors.mPaymentMethod.WasPassed()) {
return;
return NS_OK;
}
// check PaymentValidationErrors.shippingAddress
if (aErrors.mShippingAddress.WasPassed()) {
AddressErrors addErrors(aErrors.mShippingAddress.Value());
if (addErrors.mAddressLine.WasPassed() &&
!addErrors.mAddressLine.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mCity.WasPassed() && !addErrors.mCity.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mCountry.WasPassed() &&
!addErrors.mCountry.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mDependentLocality.WasPassed() &&
!addErrors.mDependentLocality.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mOrganization.WasPassed() &&
!addErrors.mOrganization.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mPhone.WasPassed() && !addErrors.mPhone.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mPostalCode.WasPassed() &&
!addErrors.mPostalCode.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mRecipient.WasPassed() &&
!addErrors.mRecipient.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mRegion.WasPassed() && !addErrors.mRegion.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mRegionCode.WasPassed() &&
!addErrors.mRegionCode.Value().IsEmpty()) {
return;
return NS_OK;
}
if (addErrors.mSortingCode.WasPassed() &&
!addErrors.mSortingCode.Value().IsEmpty()) {
return;
return NS_OK;
}
}
if (doc) {
const char16_t* params[] = { mRequestId.get() };
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("DOM::Web Payments"),
doc,
nsContentUtils::eDOM_PROPERTIES,
"PaymentRequestRetryWithEmptyErrors",
params,
1);
}
return NS_ERROR_DOM_ABORT_ERR;
}
NS_IMETHODIMP

View File

@ -146,7 +146,8 @@ class PaymentResponse final : public DOMEventTargetHelper,
protected:
~PaymentResponse();
void ValidatePaymentValidationErrors(const PaymentValidationErrors& aErrors);
nsresult ValidatePaymentValidationErrors(
const PaymentValidationErrors& aErrors);
nsresult ConvertPaymentMethodErrors(JSContext* aCx,
const PaymentValidationErrors& aErrors,

View File

@ -129,7 +129,6 @@ function checkPaymentMethodErrors(testName, errors) {
const DummyUIService = {
testName: "",
rejectRetry: false,
emptyErrors: false,
showPayment(requestId) {
acceptPayment(requestId, "show");
},
@ -144,32 +143,13 @@ const DummyUIService = {
},
updatePayment(requestId) {
const payment = paymentSrv.getPaymentRequestById(requestId);
if (!DummyUIService.emptyErrors) {
if (payment.paymentDetails.error !== "error") {
emitTestFail("Expect 'error' on details.error, but got '" +
payment.paymentDetails.error + "'");
}
checkAddressErrors(this.testName, payment.paymentDetails.shippingAddressErrors)
checkPayerErrors(this.testName, payment.paymentDetails.payerErrors);
checkPaymentMethodErrors(this.testName, payment.paymentDetails.paymentMethodErrors);
} else {
if (payment.paymentDetails.error) {
emitTestFail(`${this.testName}: Expect null on details.error, but got
'${payment.paymentDetails.error}'`);
}
if (payment.paymentDetails.payer) {
emitTestFail(`${this.testName}: Expect null on details.payer, but got
'${payment.paymentDetails.payer}'`);
}
if (payment.paymentDetails.shippingAddressErrors) {
emitTestFail(`${this.testName}: Expect null on details.shippingAddressErrors,
but got '${payment.paymentDetails.shippingAddressErrors}'`);
}
if (payment.paymentDetails.paymentMethod) {
emitTestFail(`${this.testName}: Expect null on details.paymentMethod, but
got '${payment.paymentDetails.paymentMethod}'`);
}
if (payment.paymentDetails.error !== "error") {
emitTestFail("Expect 'error' on details.error, but got '" +
payment.paymentDetails.error + "'");
}
checkAddressErrors(this.testName, payment.paymentDetails.shippingAddressErrors)
checkPayerErrors(this.testName, payment.paymentDetails.payerErrors);
checkPaymentMethodErrors(this.testName, payment.paymentDetails.paymentMethodErrors);
if (this.rejectRetry) {
rejectPayment(requestId);
} else {
@ -184,11 +164,6 @@ paymentSrv.setTestingUIService(DummyUIService.QueryInterface(Ci.nsIPaymentUIServ
addMessageListener("start-test", function(testName) {
DummyUIService.testName = testName;
if (testName === "testRetryWithEmptyErrors") {
DummyUIService.emptyErrors = true;
} else {
DummyUIService.emptyErrors = false;
}
sendAsyncMessage("start-test-complete");
});

View File

@ -209,7 +209,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1435161
const payRequest = new PaymentRequest(defaultMethods, defaultDetails, options);
ok(payRequest, testName + ": failed to create PaymentRequest.");
if (!payRequest) {
await requestChromeAction("finish-test");
requestChromeAction("finish-test");
return;
}
const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
@ -226,10 +226,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1435161
}
try {
await payResponse.retry();
} catch(err) {
ok(false, unexpectedErrMsg(testName, err.name, "retrying"));
ok(false, `${testName}: Unexpected success when retry the PaymentResponse.`);
await requestChromeAction("finish-test");
return;
} catch(err) {
is(err.name,
"AbortError",
expectedErrMsg(testName, "AbortError", err.name, "retrying"));
}
try {
await payResponse.complete("success");