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

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

Issue 2355463002: [PaymentReqeust] Add error message in PaymentDetails. (in blink side) (Closed)
Patch Set: rebase from origin Created 4 years, 3 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 5c93ec672f06aaed3b52fbe945496dfabf380d10..eb99da3b100e61ed9dc166a9271c3269df250ad7 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
@@ -35,7 +35,6 @@ TEST(PaymentRequestTest, NoExceptionWithValidData)
EXPECT_FALSE(scope.getExceptionState().hadException());
}
-
TEST(PaymentRequestTest, SupportedMethodListRequired)
{
V8TestingScope scope;
@@ -56,6 +55,16 @@ TEST(PaymentRequestTest, TotalRequired)
EXPECT_EQ(V8TypeError, scope.getExceptionState().code());
}
+TEST(PaymentRequestTest, ErrorMsgMustBeEmptyInConstrctor)
+{
+ V8TestingScope scope;
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), buildPaymentDetailsErrorMsgForTest("This is an error message."), scope.getExceptionState());
+
+ EXPECT_TRUE(scope.getExceptionState().hadException());
+ EXPECT_EQ(V8TypeError, scope.getExceptionState().code());
+}
+
TEST(PaymentRequestTest, NullShippingOptionWhenNoOptionsAvailable)
{
V8TestingScope scope;
@@ -466,5 +475,21 @@ TEST(PaymentRequestTest, UseTheSelectedShippingOptionFromPaymentDetailsUpdate)
EXPECT_EQ("fast", request->shippingOption());
}
+TEST(PaymentRequestTest, NoExceptionWithErrorMessageInUpdate)
+{
+ V8TestingScope scope;
+ PaymentRequestMockFunctionScope funcs(scope.getScriptState());
+ makePaymentRequestOriginSecure(scope.document());
+ PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), buildPaymentMethodDataForTest(), buildPaymentDetailsForTest(), scope.getExceptionState());
+ EXPECT_FALSE(scope.getExceptionState().hadException());
+
+ request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expectNoCall());
+ String detailWithErrorMsg = "{\"total\": {\"label\": \"Total\", \"amount\": {\"currency\": \"USD\", \"value\": \"5.00\"}},"
+ "\"error\": \"This is an error message.\"}";
+
+ request->onUpdatePaymentDetails(ScriptValue::from(scope.getScriptState(), fromJSONString(scope.getScriptState(), detailWithErrorMsg, scope.getExceptionState())));
+ EXPECT_FALSE(scope.getExceptionState().hadException());
+}
+
} // namespace
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698