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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEventTest.cpp

Issue 2697123003: Use ExecutionContext instead of Document in PaymentRequest constructor. (Closed)
Patch Set: ExecutionContext in constructor only Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "modules/payments/PaymentRequestUpdateEvent.h" 5 #include "modules/payments/PaymentRequestUpdateEvent.h"
6 6
7 #include <memory>
7 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
9 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8BindingForTesting.h" 11 #include "bindings/core/v8/V8BindingForTesting.h"
11 #include "core/EventTypeNames.h" 12 #include "core/EventTypeNames.h"
12 #include "modules/payments/PaymentRequest.h" 13 #include "modules/payments/PaymentRequest.h"
13 #include "modules/payments/PaymentTestHelper.h" 14 #include "modules/payments/PaymentTestHelper.h"
14 #include "modules/payments/PaymentUpdater.h" 15 #include "modules/payments/PaymentUpdater.h"
15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 #include <memory>
18 18
19 namespace blink { 19 namespace blink {
20 namespace { 20 namespace {
21 21
22 class MockPaymentUpdater : public GarbageCollectedFinalized<MockPaymentUpdater>, 22 class MockPaymentUpdater : public GarbageCollectedFinalized<MockPaymentUpdater>,
23 public PaymentUpdater { 23 public PaymentUpdater {
24 USING_GARBAGE_COLLECTED_MIXIN(MockPaymentUpdater); 24 USING_GARBAGE_COLLECTED_MIXIN(MockPaymentUpdater);
25 WTF_MAKE_NONCOPYABLE(MockPaymentUpdater); 25 WTF_MAKE_NONCOPYABLE(MockPaymentUpdater);
26 26
27 public: 27 public:
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 scope.getExceptionState()); 119 scope.getExceptionState());
120 120
121 EXPECT_FALSE(scope.getExceptionState().hadException()); 121 EXPECT_FALSE(scope.getExceptionState().hadException());
122 } 122 }
123 123
124 TEST(PaymentRequestUpdateEventTest, OnUpdatePaymentDetailsTimeout) { 124 TEST(PaymentRequestUpdateEventTest, OnUpdatePaymentDetailsTimeout) {
125 V8TestingScope scope; 125 V8TestingScope scope;
126 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 126 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
127 makePaymentRequestOriginSecure(scope.document()); 127 makePaymentRequestOriginSecure(scope.document());
128 PaymentRequest* request = PaymentRequest::create( 128 PaymentRequest* request = PaymentRequest::create(
129 scope.document(), buildPaymentMethodDataForTest(), 129 scope.getExecutionContext(), buildPaymentMethodDataForTest(),
130 buildPaymentDetailsForTest(), scope.getExceptionState()); 130 buildPaymentDetailsForTest(), scope.getExceptionState());
131 PaymentRequestUpdateEvent* event = PaymentRequestUpdateEvent::create( 131 PaymentRequestUpdateEvent* event = PaymentRequestUpdateEvent::create(
132 scope.getExecutionContext(), EventTypeNames::shippingaddresschange); 132 scope.getExecutionContext(), EventTypeNames::shippingaddresschange);
133 event->setPaymentDetailsUpdater(request); 133 event->setPaymentDetailsUpdater(request);
134 EXPECT_FALSE(scope.getExceptionState().hadException()); 134 EXPECT_FALSE(scope.getExceptionState().hadException());
135 135
136 String errorMessage; 136 String errorMessage;
137 request->show(scope.getScriptState()) 137 request->show(scope.getScriptState())
138 .then(funcs.expectNoCall(), funcs.expectCall(&errorMessage)); 138 .then(funcs.expectNoCall(), funcs.expectCall(&errorMessage));
139 139
140 event->onUpdateEventTimeoutForTesting(); 140 event->onUpdateEventTimeoutForTesting();
141 141
142 v8::MicrotasksScope::PerformCheckpoint(scope.getScriptState()->isolate()); 142 v8::MicrotasksScope::PerformCheckpoint(scope.getScriptState()->isolate());
143 EXPECT_EQ( 143 EXPECT_EQ(
144 "AbortError: Timed out as the page didn't resolve the promise from " 144 "AbortError: Timed out as the page didn't resolve the promise from "
145 "change event", 145 "change event",
146 errorMessage); 146 errorMessage);
147 } 147 }
148 148
149 } // namespace 149 } // namespace
150 } // namespace blink 150 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698