Bug 1633344 - Throw RangeError when creating PaymentRequest with a duplicate payment method. r=alchen
Differential Revision: https://phabricator.services.mozilla.com/D74686
This commit is contained in:
@@ -305,6 +305,7 @@ void PaymentRequest::IsValidMethodData(
|
||||
return;
|
||||
}
|
||||
|
||||
nsTArray<nsString> methods;
|
||||
for (const PaymentMethodData& methodData : aMethodData) {
|
||||
IsValidPaymentMethodIdentifier(methodData.mSupportedMethods, aRv);
|
||||
if (aRv.Failed()) {
|
||||
@@ -325,6 +326,13 @@ void PaymentRequest::IsValidMethodData(
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!methods.Contains(methodData.mSupportedMethods)) {
|
||||
methods.AppendElement(methodData.mSupportedMethods);
|
||||
} else {
|
||||
aRv.ThrowRangeError(nsPrintfCString(
|
||||
"Duplicate payment method '%s'",
|
||||
NS_ConvertUTF16toUTF8(methodData.mSupportedMethods).get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user