Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2137953002: Duplicate shipping option identifiers should throw TypeError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch3 Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index 386f630876a9c71a1349abdb661c91fee410b93f..c24a730fddef7b5b1540b0bc0b01d1fd36cbe3af 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -206,12 +206,19 @@ void validateDisplayItems(const HeapVector<PaymentItem>& items, ExceptionState&
void validateShippingOptions(const HeapVector<PaymentShippingOption>& options, ExceptionState& exceptionState)
{
+ HashSet<String> uniqueIds;
for (const auto& option : options) {
if (!option.hasId() || option.id().isEmpty()) {
exceptionState.throwTypeError("ShippingOption id required");
return;
}
+ if (uniqueIds.contains(option.id())) {
+ exceptionState.throwTypeError("Duplicate shipping option identifiers are not allowed");
+ return;
+ }
+ uniqueIds.add(option.id());
+
validateShippingOptionOrPaymentItem(option, exceptionState);
if (exceptionState.hadException())
return;
@@ -231,6 +238,7 @@ void validatePaymentDetailsModifiers(const HeapVector<PaymentDetailsModifier>& m
exceptionState.throwTypeError("Must specify at least one payment method identifier");
return;
}
+
for (const auto& method : modifier.supportedMethods()) {
if (uniqueMethods.contains(method)) {
exceptionState.throwTypeError("Duplicate payment method identifiers are not allowed");
@@ -304,6 +312,7 @@ void validateAndConvertPaymentMethodData(const HeapVector<PaymentMethodData>& pa
exceptionState.throwTypeError("Must specify at least one payment method identifier");
return;
}
+
for (const auto& method : pmd.supportedMethods()) {
if (uniqueMethods.contains(method)) {
exceptionState.throwTypeError("Duplicate payment method identifiers are not allowed");

Powered by Google App Engine
This is Rietveld 408576698