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

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

Issue 2406713002: PaymentRequest: Ignore shipping options if there are duplicated IDs. (Closed)
Patch Set: presubmit Created 4 years, 2 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/PaymentRequestTest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
index 78bb515d40c44e24258d2adb45258faa1224ccfe..6b964ad49d445573fa0992e220920eae0f586e77 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
@@ -598,5 +598,46 @@ TEST(PaymentRequestTest, NoExceptionWithErrorMessageInUpdate) {
EXPECT_FALSE(scope.getExceptionState().hadException());
}
+TEST(PaymentRequestTest,
+ ShouldResolveWithEmptyShippingOptionsIfIDsOfShippingOptionsAreDuplicated) {
+ V8TestingScope scope;
+ PaymentRequestMockFunctionScope funcs(scope.getScriptState());
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentDetails details;
+ details.setTotal(buildPaymentItemForTest());
+ HeapVector<PaymentShippingOption> shippingOptions(2);
+ shippingOptions[0] = buildShippingOptionForTest(
+ PaymentTestDataId, PaymentTestOverwriteValue, "standard");
+ shippingOptions[0].setSelected(true);
+ shippingOptions[1] = buildShippingOptionForTest(
+ PaymentTestDataId, PaymentTestOverwriteValue, "standard");
+ details.setShippingOptions(shippingOptions);
+ PaymentOptions options;
+ options.setRequestShipping(true);
+ PaymentRequest* request = PaymentRequest::create(
+ scope.getScriptState(), buildPaymentMethodDataForTest(), details, options,
+ scope.getExceptionState());
+ EXPECT_FALSE(scope.getExceptionState().hadException());
+ EXPECT_TRUE(request->shippingOption().isNull());
+ request->show(scope.getScriptState())
+ .then(funcs.expectNoCall(), funcs.expectNoCall());
+ String detailWithShippingOptions =
+ "{\"total\": {\"label\": \"Total\", \"amount\": {\"currency\": \"USD\", "
+ "\"value\": \"5.00\"}},"
+ "\"shippingOptions\": [{\"id\": \"standardShippingOption\", \"label\": "
+ "\"Standard shipping\", \"amount\": {\"currency\": \"USD\", \"value\": "
+ "\"5.00\"}, \"selected\": true}, {\"id\": \"standardShippingOption\", "
+ "\"label\": \"Standard shipping\", \"amount\": {\"currency\": \"USD\", "
+ "\"value\": \"5.00\"}, \"selected\": true}]}";
+
+ request->onUpdatePaymentDetails(ScriptValue::from(
+ scope.getScriptState(),
+ fromJSONString(scope.getScriptState(), detailWithShippingOptions,
+ scope.getExceptionState())));
+
+ EXPECT_FALSE(scope.getExceptionState().hadException());
+ EXPECT_TRUE(request->shippingOption().isNull());
+}
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698