| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Tests for PaymentRequest::abort(). | 5 // Tests for PaymentRequest::abort(). |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8BindingForTesting.h" | 7 #include "bindings/core/v8/V8BindingForTesting.h" |
| 8 #include "modules/payments/PaymentRequest.h" | 8 #include "modules/payments/PaymentRequest.h" |
| 9 #include "modules/payments/PaymentTestHelper.h" | 9 #include "modules/payments/PaymentTestHelper.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 64 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 65 makePaymentRequestOriginSecure(scope.document()); | 65 makePaymentRequestOriginSecure(scope.document()); |
| 66 PaymentRequest* request = PaymentRequest::create( | 66 PaymentRequest* request = PaymentRequest::create( |
| 67 scope.getScriptState(), buildPaymentMethodDataForTest(), | 67 scope.getScriptState(), buildPaymentMethodDataForTest(), |
| 68 buildPaymentDetailsForTest(), scope.getExceptionState()); | 68 buildPaymentDetailsForTest(), scope.getExceptionState()); |
| 69 request->show(scope.getScriptState()); | 69 request->show(scope.getScriptState()); |
| 70 | 70 |
| 71 request->abort(scope.getScriptState()) | 71 request->abort(scope.getScriptState()) |
| 72 .then(funcs.expectNoCall(), funcs.expectCall()); | 72 .then(funcs.expectNoCall(), funcs.expectCall()); |
| 73 | 73 |
| 74 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)->OnAbort( | 74 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(false); |
| 75 false); | |
| 76 } | 75 } |
| 77 | 76 |
| 78 // After the browser is unable to abort the payment once, the second abort() | 77 // After the browser is unable to abort the payment once, the second abort() |
| 79 // call should not be rejected, as it's not a duplicate request anymore. | 78 // call should not be rejected, as it's not a duplicate request anymore. |
| 80 TEST(AbortTest, CanAbortAgainAfterFirstAbortRejected) { | 79 TEST(AbortTest, CanAbortAgainAfterFirstAbortRejected) { |
| 81 V8TestingScope scope; | 80 V8TestingScope scope; |
| 82 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 81 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 83 makePaymentRequestOriginSecure(scope.document()); | 82 makePaymentRequestOriginSecure(scope.document()); |
| 84 PaymentRequest* request = PaymentRequest::create( | 83 PaymentRequest* request = PaymentRequest::create( |
| 85 scope.getScriptState(), buildPaymentMethodDataForTest(), | 84 scope.getScriptState(), buildPaymentMethodDataForTest(), |
| 86 buildPaymentDetailsForTest(), scope.getExceptionState()); | 85 buildPaymentDetailsForTest(), scope.getExceptionState()); |
| 87 request->show(scope.getScriptState()); | 86 request->show(scope.getScriptState()); |
| 88 request->abort(scope.getScriptState()); | 87 request->abort(scope.getScriptState()); |
| 89 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)->OnAbort( | 88 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(false); |
| 90 false); | |
| 91 | 89 |
| 92 request->abort(scope.getScriptState()) | 90 request->abort(scope.getScriptState()) |
| 93 .then(funcs.expectNoCall(), funcs.expectNoCall()); | 91 .then(funcs.expectNoCall(), funcs.expectNoCall()); |
| 94 } | 92 } |
| 95 | 93 |
| 96 // If the browser successfully aborts the payment, then the request.show() | 94 // If the browser successfully aborts the payment, then the request.show() |
| 97 // promise should be rejected, and request.abort() promise should be resolved. | 95 // promise should be rejected, and request.abort() promise should be resolved. |
| 98 TEST(AbortTest, SuccessfulAbortShouldRejectShowPromiseAndResolveAbortPromise) { | 96 TEST(AbortTest, SuccessfulAbortShouldRejectShowPromiseAndResolveAbortPromise) { |
| 99 V8TestingScope scope; | 97 V8TestingScope scope; |
| 100 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 98 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 101 makePaymentRequestOriginSecure(scope.document()); | 99 makePaymentRequestOriginSecure(scope.document()); |
| 102 PaymentRequest* request = PaymentRequest::create( | 100 PaymentRequest* request = PaymentRequest::create( |
| 103 scope.getScriptState(), buildPaymentMethodDataForTest(), | 101 scope.getScriptState(), buildPaymentMethodDataForTest(), |
| 104 buildPaymentDetailsForTest(), scope.getExceptionState()); | 102 buildPaymentDetailsForTest(), scope.getExceptionState()); |
| 105 | 103 |
| 106 request->show(scope.getScriptState()) | 104 request->show(scope.getScriptState()) |
| 107 .then(funcs.expectNoCall(), funcs.expectCall()); | 105 .then(funcs.expectNoCall(), funcs.expectCall()); |
| 108 request->abort(scope.getScriptState()) | 106 request->abort(scope.getScriptState()) |
| 109 .then(funcs.expectCall(), funcs.expectNoCall()); | 107 .then(funcs.expectCall(), funcs.expectNoCall()); |
| 110 | 108 |
| 111 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)->OnAbort( | 109 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnAbort(true); |
| 112 true); | |
| 113 } | 110 } |
| 114 | 111 |
| 115 } // namespace | 112 } // namespace |
| 116 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |