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

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

Issue 2083883003: Reject PaymentResponse.complete() promise on error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 dbc425cb61b39523b10741142808797849e7999d..50cf1db993900ae65b9c91b4f46bb48428a9c812 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
@@ -265,6 +265,22 @@ TEST(PaymentRequestTest, RejectCompletePromiseOnError)
static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError();
}
+// If user cancels the transaction during processing, the complete() promise
+// should be rejected.
+TEST(PaymentRequestTest, RejectCompletePromiseAfterError)
+{
+ 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());
+ static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(buildPaymentResponseForTest());
+ static_cast<mojom::blink::PaymentRequestClient*>(request)->OnError();
+
+ request->complete(scope.getScriptState(), Success).then(funcs.expectNoCall(), funcs.expectCall());
+}
+
TEST(PaymentRequestTest, ResolvePromiseOnComplete)
{
V8TestingScope scope;

Powered by Google App Engine
This is Rietveld 408576698