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 d15c8f6a6fdc3633bc9e97cf9241d4e449e1703f..c9f22ef71046a58b073688c9a3e80b011f3a1f5e 100644 |
--- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp |
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp |
@@ -21,7 +21,7 @@ |
PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_TRUE(scope.getExceptionState().hadException()); |
EXPECT_EQ(SecurityError, scope.getExceptionState().code()); |
@@ -32,7 +32,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
} |
@@ -42,7 +42,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest::create( |
scope.getExecutionContext(), HeapVector<PaymentMethodData>(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_TRUE(scope.getExceptionState().hadException()); |
EXPECT_EQ(V8TypeError, scope.getExceptionState().code()); |
@@ -52,17 +52,29 @@ |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest::create(scope.getExecutionContext(), |
- buildPaymentMethodDataForTest(), PaymentDetailsInit(), |
+ buildPaymentMethodDataForTest(), PaymentDetails(), |
scope.getExceptionState()); |
EXPECT_TRUE(scope.getExceptionState().hadException()); |
EXPECT_EQ(V8TypeError, scope.getExceptionState().code()); |
} |
+TEST(PaymentRequestTest, ErrorMsgMustBeEmptyInConstrctor) { |
+ V8TestingScope scope; |
+ makePaymentRequestOriginSecure(scope.document()); |
+ PaymentRequest::create( |
+ scope.getExecutionContext(), 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; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(true); |
@@ -77,7 +89,7 @@ |
TEST(PaymentRequestTest, NullShippingOptionWhenMultipleOptionsAvailable) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
details.setShippingOptions( |
HeapVector<PaymentShippingOption>(2, buildShippingOptionForTest())); |
@@ -94,7 +106,7 @@ |
TEST(PaymentRequestTest, DontSelectSingleAvailableShippingOptionByDefault) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
details.setShippingOptions(HeapVector<PaymentShippingOption>( |
1, |
@@ -112,7 +124,7 @@ |
DontSelectSingleAvailableShippingOptionWhenShippingNotRequested) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
details.setShippingOptions( |
HeapVector<PaymentShippingOption>(1, buildShippingOptionForTest())); |
@@ -130,7 +142,7 @@ |
DontSelectSingleUnselectedShippingOptionWhenShippingRequested) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
details.setShippingOptions( |
HeapVector<PaymentShippingOption>(1, buildShippingOptionForTest())); |
@@ -148,7 +160,7 @@ |
SelectSingleSelectedShippingOptionWhenShippingRequested) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
HeapVector<PaymentShippingOption> shippingOptions( |
1, |
@@ -170,7 +182,7 @@ |
SelectOnlySelectedShippingOptionWhenShippingRequested) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
HeapVector<PaymentShippingOption> shippingOptions(2); |
shippingOptions[0] = buildShippingOptionForTest( |
@@ -193,7 +205,7 @@ |
SelectLastSelectedShippingOptionWhenShippingRequested) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
HeapVector<PaymentShippingOption> shippingOptions(2); |
shippingOptions[0] = buildShippingOptionForTest( |
@@ -216,7 +228,7 @@ |
TEST(PaymentRequestTest, NullShippingTypeWhenRequestShippingIsFalse) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(false); |
@@ -232,7 +244,7 @@ |
DefaultShippingTypeWhenRequestShippingIsTrueWithNoSpecificType) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(true); |
@@ -247,7 +259,7 @@ |
TEST(PaymentRequestTest, DeliveryShippingTypeWhenShippingTypeIsDelivery) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(true); |
@@ -263,7 +275,7 @@ |
TEST(PaymentRequestTest, PickupShippingTypeWhenShippingTypeIsPickup) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(true); |
@@ -279,7 +291,7 @@ |
TEST(PaymentRequestTest, DefaultShippingTypeWhenShippingTypeIsInvalid) { |
V8TestingScope scope; |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(true); |
@@ -298,7 +310,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
@@ -314,7 +326,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
@@ -330,7 +342,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()); |
@@ -344,7 +356,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()); |
request->abort(scope.getScriptState()); |
@@ -361,7 +373,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
String errorMessage; |
@@ -382,7 +394,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
String errorMessage; |
@@ -402,7 +414,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
String errorMessage; |
@@ -421,7 +433,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
.then(funcs.expectCall(), funcs.expectNoCall()); |
@@ -438,7 +450,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
@@ -454,16 +466,16 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
.then(funcs.expectNoCall(), funcs.expectCall()); |
- request->onUpdatePaymentDetails(ScriptValue::from( |
- scope.getScriptState(), |
- fromJSONString(scope.getScriptState()->isolate(), "{\"total\": {}}", |
- scope.getExceptionState()))); |
+ request->onUpdatePaymentDetails( |
+ ScriptValue::from(scope.getScriptState(), |
+ fromJSONString(scope.getScriptState()->isolate(), "{}", |
+ scope.getExceptionState()))); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
} |
@@ -472,7 +484,7 @@ |
V8TestingScope scope; |
PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
PaymentOptions options; |
options.setRequestShipping(true); |
@@ -518,7 +530,7 @@ |
options.setRequestShipping(true); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), options, scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), options, scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
.then(funcs.expectNoCall(), funcs.expectNoCall()); |
@@ -547,7 +559,7 @@ |
options.setRequestShipping(true); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), options, scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), options, scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
.then(funcs.expectNoCall(), funcs.expectNoCall()); |
@@ -574,7 +586,7 @@ |
makePaymentRequestOriginSecure(scope.document()); |
PaymentRequest* request = PaymentRequest::create( |
scope.getExecutionContext(), buildPaymentMethodDataForTest(), |
- buildPaymentDetailsInitForTest(), scope.getExceptionState()); |
+ buildPaymentDetailsForTest(), scope.getExceptionState()); |
EXPECT_FALSE(scope.getExceptionState().hadException()); |
request->show(scope.getScriptState()) |
@@ -596,7 +608,7 @@ |
V8TestingScope scope; |
PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
makePaymentRequestOriginSecure(scope.document()); |
- PaymentDetailsInit details; |
+ PaymentDetails details; |
details.setTotal(buildPaymentItemForTest()); |
HeapVector<PaymentShippingOption> shippingOptions(2); |
shippingOptions[0] = buildShippingOptionForTest( |