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

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

Issue 2477883002: [Web Payments] Mojom namespace blink -> payments (Closed)
Patch Set: Fix WebKit tests Created 4 years, 1 month 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
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 // Tests for PaymentRequest::OnPaymentResponse(). 5 // Tests for PaymentRequest::OnPaymentResponse().
6 6
7 #include "bindings/core/v8/ScriptFunction.h" 7 #include "bindings/core/v8/ScriptFunction.h"
8 #include "bindings/core/v8/V8BindingForTesting.h" 8 #include "bindings/core/v8/V8BindingForTesting.h"
9 #include "bindings/modules/v8/V8PaymentResponse.h" 9 #include "bindings/modules/v8/V8PaymentResponse.h"
10 #include "modules/payments/PaymentAddress.h" 10 #include "modules/payments/PaymentAddress.h"
(...skipping 10 matching lines...) Expand all
21 TEST(OnPaymentResponseTest, RejectMissingShippingOption) { 21 TEST(OnPaymentResponseTest, RejectMissingShippingOption) {
22 V8TestingScope scope; 22 V8TestingScope scope;
23 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 23 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
24 makePaymentRequestOriginSecure(scope.document()); 24 makePaymentRequestOriginSecure(scope.document());
25 PaymentOptions options; 25 PaymentOptions options;
26 options.setRequestShipping(true); 26 options.setRequestShipping(true);
27 PaymentRequest* request = PaymentRequest::create( 27 PaymentRequest* request = PaymentRequest::create(
28 scope.getScriptState(), buildPaymentMethodDataForTest(), 28 scope.getScriptState(), buildPaymentMethodDataForTest(),
29 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 29 buildPaymentDetailsForTest(), options, scope.getExceptionState());
30 ASSERT_FALSE(scope.getExceptionState().hadException()); 30 ASSERT_FALSE(scope.getExceptionState().hadException());
31 mojom::blink::PaymentResponsePtr response = buildPaymentResponseForTest(); 31 payments::mojom::blink::PaymentResponsePtr response =
32 response->shipping_address = mojom::blink::PaymentAddress::New(); 32 buildPaymentResponseForTest();
33 response->shipping_address = payments::mojom::blink::PaymentAddress::New();
33 response->shipping_address->country = "US"; 34 response->shipping_address->country = "US";
34 response->shipping_address->language_code = "en"; 35 response->shipping_address->language_code = "en";
35 response->shipping_address->script_code = "Latn"; 36 response->shipping_address->script_code = "Latn";
36 37
37 request->show(scope.getScriptState()) 38 request->show(scope.getScriptState())
38 .then(funcs.expectNoCall(), funcs.expectCall()); 39 .then(funcs.expectNoCall(), funcs.expectCall());
39 40
40 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 41 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
41 std::move(response)); 42 ->OnPaymentResponse(std::move(response));
42 } 43 }
43 44
44 // If the merchant requests shipping information, but the browser does not 45 // If the merchant requests shipping information, but the browser does not
45 // provide a shipping address, reject the show() promise. 46 // provide a shipping address, reject the show() promise.
46 TEST(OnPaymentResponseTest, RejectMissingAddress) { 47 TEST(OnPaymentResponseTest, RejectMissingAddress) {
47 V8TestingScope scope; 48 V8TestingScope scope;
48 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 49 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
49 makePaymentRequestOriginSecure(scope.document()); 50 makePaymentRequestOriginSecure(scope.document());
50 PaymentOptions options; 51 PaymentOptions options;
51 options.setRequestShipping(true); 52 options.setRequestShipping(true);
52 PaymentRequest* request = PaymentRequest::create( 53 PaymentRequest* request = PaymentRequest::create(
53 scope.getScriptState(), buildPaymentMethodDataForTest(), 54 scope.getScriptState(), buildPaymentMethodDataForTest(),
54 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 55 buildPaymentDetailsForTest(), options, scope.getExceptionState());
55 ASSERT_FALSE(scope.getExceptionState().hadException()); 56 ASSERT_FALSE(scope.getExceptionState().hadException());
56 mojom::blink::PaymentResponsePtr response = buildPaymentResponseForTest(); 57 payments::mojom::blink::PaymentResponsePtr response =
58 buildPaymentResponseForTest();
57 response->shipping_option = "standardShipping"; 59 response->shipping_option = "standardShipping";
58 60
59 request->show(scope.getScriptState()) 61 request->show(scope.getScriptState())
60 .then(funcs.expectNoCall(), funcs.expectCall()); 62 .then(funcs.expectNoCall(), funcs.expectCall());
61 63
62 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 64 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
63 std::move(response)); 65 ->OnPaymentResponse(std::move(response));
64 } 66 }
65 67
66 // If the merchant requests a payer name, but the browser does not provide it, 68 // If the merchant requests a payer name, but the browser does not provide it,
67 // reject the show() promise. 69 // reject the show() promise.
68 TEST(OnPaymentResponseTest, RejectMissingName) { 70 TEST(OnPaymentResponseTest, RejectMissingName) {
69 V8TestingScope scope; 71 V8TestingScope scope;
70 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 72 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
71 makePaymentRequestOriginSecure(scope.document()); 73 makePaymentRequestOriginSecure(scope.document());
72 PaymentOptions options; 74 PaymentOptions options;
73 options.setRequestPayerName(true); 75 options.setRequestPayerName(true);
74 PaymentRequest* request = PaymentRequest::create( 76 PaymentRequest* request = PaymentRequest::create(
75 scope.getScriptState(), buildPaymentMethodDataForTest(), 77 scope.getScriptState(), buildPaymentMethodDataForTest(),
76 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 78 buildPaymentDetailsForTest(), options, scope.getExceptionState());
77 EXPECT_FALSE(scope.getExceptionState().hadException()); 79 EXPECT_FALSE(scope.getExceptionState().hadException());
78 mojom::blink::PaymentResponsePtr response = 80 payments::mojom::blink::PaymentResponsePtr response =
79 mojom::blink::PaymentResponse::New(); 81 payments::mojom::blink::PaymentResponse::New();
80 82
81 request->show(scope.getScriptState()) 83 request->show(scope.getScriptState())
82 .then(funcs.expectNoCall(), funcs.expectCall()); 84 .then(funcs.expectNoCall(), funcs.expectCall());
83 85
84 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 86 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
85 std::move(response)); 87 ->OnPaymentResponse(std::move(response));
86 } 88 }
87 89
88 // If the merchant requests an email address, but the browser does not provide 90 // If the merchant requests an email address, but the browser does not provide
89 // it, reject the show() promise. 91 // it, reject the show() promise.
90 TEST(OnPaymentResponseTest, RejectMissingEmail) { 92 TEST(OnPaymentResponseTest, RejectMissingEmail) {
91 V8TestingScope scope; 93 V8TestingScope scope;
92 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 94 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
93 makePaymentRequestOriginSecure(scope.document()); 95 makePaymentRequestOriginSecure(scope.document());
94 PaymentOptions options; 96 PaymentOptions options;
95 options.setRequestPayerEmail(true); 97 options.setRequestPayerEmail(true);
96 PaymentRequest* request = PaymentRequest::create( 98 PaymentRequest* request = PaymentRequest::create(
97 scope.getScriptState(), buildPaymentMethodDataForTest(), 99 scope.getScriptState(), buildPaymentMethodDataForTest(),
98 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 100 buildPaymentDetailsForTest(), options, scope.getExceptionState());
99 EXPECT_FALSE(scope.getExceptionState().hadException()); 101 EXPECT_FALSE(scope.getExceptionState().hadException());
100 mojom::blink::PaymentResponsePtr response = 102 payments::mojom::blink::PaymentResponsePtr response =
101 mojom::blink::PaymentResponse::New(); 103 payments::mojom::blink::PaymentResponse::New();
102 104
103 request->show(scope.getScriptState()) 105 request->show(scope.getScriptState())
104 .then(funcs.expectNoCall(), funcs.expectCall()); 106 .then(funcs.expectNoCall(), funcs.expectCall());
105 107
106 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 108 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
107 std::move(response)); 109 ->OnPaymentResponse(std::move(response));
108 } 110 }
109 111
110 // If the merchant requests a phone number, but the browser does not provide it, 112 // If the merchant requests a phone number, but the browser does not provide it,
111 // reject the show() promise. 113 // reject the show() promise.
112 TEST(OnPaymentResponseTest, RejectMissingPhone) { 114 TEST(OnPaymentResponseTest, RejectMissingPhone) {
113 V8TestingScope scope; 115 V8TestingScope scope;
114 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 116 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
115 makePaymentRequestOriginSecure(scope.document()); 117 makePaymentRequestOriginSecure(scope.document());
116 PaymentOptions options; 118 PaymentOptions options;
117 options.setRequestPayerPhone(true); 119 options.setRequestPayerPhone(true);
118 PaymentRequest* request = PaymentRequest::create( 120 PaymentRequest* request = PaymentRequest::create(
119 scope.getScriptState(), buildPaymentMethodDataForTest(), 121 scope.getScriptState(), buildPaymentMethodDataForTest(),
120 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 122 buildPaymentDetailsForTest(), options, scope.getExceptionState());
121 EXPECT_FALSE(scope.getExceptionState().hadException()); 123 EXPECT_FALSE(scope.getExceptionState().hadException());
122 mojom::blink::PaymentResponsePtr response = 124 payments::mojom::blink::PaymentResponsePtr response =
123 mojom::blink::PaymentResponse::New(); 125 payments::mojom::blink::PaymentResponse::New();
124 126
125 request->show(scope.getScriptState()) 127 request->show(scope.getScriptState())
126 .then(funcs.expectNoCall(), funcs.expectCall()); 128 .then(funcs.expectNoCall(), funcs.expectCall());
127 129
128 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 130 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
129 std::move(response)); 131 ->OnPaymentResponse(std::move(response));
130 } 132 }
131 133
132 // If the merchant requests shipping information, but the browser provides an 134 // If the merchant requests shipping information, but the browser provides an
133 // empty string for shipping option, reject the show() promise. 135 // empty string for shipping option, reject the show() promise.
134 TEST(OnPaymentResponseTest, RejectEmptyShippingOption) { 136 TEST(OnPaymentResponseTest, RejectEmptyShippingOption) {
135 V8TestingScope scope; 137 V8TestingScope scope;
136 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 138 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
137 makePaymentRequestOriginSecure(scope.document()); 139 makePaymentRequestOriginSecure(scope.document());
138 PaymentOptions options; 140 PaymentOptions options;
139 options.setRequestShipping(true); 141 options.setRequestShipping(true);
140 PaymentRequest* request = PaymentRequest::create( 142 PaymentRequest* request = PaymentRequest::create(
141 scope.getScriptState(), buildPaymentMethodDataForTest(), 143 scope.getScriptState(), buildPaymentMethodDataForTest(),
142 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 144 buildPaymentDetailsForTest(), options, scope.getExceptionState());
143 ASSERT_FALSE(scope.getExceptionState().hadException()); 145 ASSERT_FALSE(scope.getExceptionState().hadException());
144 mojom::blink::PaymentResponsePtr response = buildPaymentResponseForTest(); 146 payments::mojom::blink::PaymentResponsePtr response =
147 buildPaymentResponseForTest();
145 response->shipping_option = ""; 148 response->shipping_option = "";
146 response->shipping_address = mojom::blink::PaymentAddress::New(); 149 response->shipping_address = payments::mojom::blink::PaymentAddress::New();
147 response->shipping_address->country = "US"; 150 response->shipping_address->country = "US";
148 response->shipping_address->language_code = "en"; 151 response->shipping_address->language_code = "en";
149 response->shipping_address->script_code = "Latn"; 152 response->shipping_address->script_code = "Latn";
150 153
151 request->show(scope.getScriptState()) 154 request->show(scope.getScriptState())
152 .then(funcs.expectNoCall(), funcs.expectCall()); 155 .then(funcs.expectNoCall(), funcs.expectCall());
153 156
154 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 157 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
155 std::move(response)); 158 ->OnPaymentResponse(std::move(response));
156 } 159 }
157 160
158 // If the merchant requests shipping information, but the browser provides an 161 // If the merchant requests shipping information, but the browser provides an
159 // empty shipping address, reject the show() promise. 162 // empty shipping address, reject the show() promise.
160 TEST(OnPaymentResponseTest, RejectEmptyAddress) { 163 TEST(OnPaymentResponseTest, RejectEmptyAddress) {
161 V8TestingScope scope; 164 V8TestingScope scope;
162 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 165 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
163 makePaymentRequestOriginSecure(scope.document()); 166 makePaymentRequestOriginSecure(scope.document());
164 PaymentOptions options; 167 PaymentOptions options;
165 options.setRequestShipping(true); 168 options.setRequestShipping(true);
166 PaymentRequest* request = PaymentRequest::create( 169 PaymentRequest* request = PaymentRequest::create(
167 scope.getScriptState(), buildPaymentMethodDataForTest(), 170 scope.getScriptState(), buildPaymentMethodDataForTest(),
168 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 171 buildPaymentDetailsForTest(), options, scope.getExceptionState());
169 ASSERT_FALSE(scope.getExceptionState().hadException()); 172 ASSERT_FALSE(scope.getExceptionState().hadException());
170 mojom::blink::PaymentResponsePtr response = buildPaymentResponseForTest(); 173 payments::mojom::blink::PaymentResponsePtr response =
174 buildPaymentResponseForTest();
171 response->shipping_option = "standardShipping"; 175 response->shipping_option = "standardShipping";
172 response->shipping_address = mojom::blink::PaymentAddress::New(); 176 response->shipping_address = payments::mojom::blink::PaymentAddress::New();
173 177
174 request->show(scope.getScriptState()) 178 request->show(scope.getScriptState())
175 .then(funcs.expectNoCall(), funcs.expectCall()); 179 .then(funcs.expectNoCall(), funcs.expectCall());
176 180
177 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 181 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
178 std::move(response)); 182 ->OnPaymentResponse(std::move(response));
179 } 183 }
180 184
181 // If the merchant requests a payer name, but the browser provides an empty 185 // If the merchant requests a payer name, but the browser provides an empty
182 // string for name, reject the show() promise. 186 // string for name, reject the show() promise.
183 TEST(OnPaymentResponseTest, RejectEmptyName) { 187 TEST(OnPaymentResponseTest, RejectEmptyName) {
184 V8TestingScope scope; 188 V8TestingScope scope;
185 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 189 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
186 makePaymentRequestOriginSecure(scope.document()); 190 makePaymentRequestOriginSecure(scope.document());
187 PaymentOptions options; 191 PaymentOptions options;
188 options.setRequestPayerName(true); 192 options.setRequestPayerName(true);
189 PaymentRequest* request = PaymentRequest::create( 193 PaymentRequest* request = PaymentRequest::create(
190 scope.getScriptState(), buildPaymentMethodDataForTest(), 194 scope.getScriptState(), buildPaymentMethodDataForTest(),
191 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 195 buildPaymentDetailsForTest(), options, scope.getExceptionState());
192 EXPECT_FALSE(scope.getExceptionState().hadException()); 196 EXPECT_FALSE(scope.getExceptionState().hadException());
193 mojom::blink::PaymentResponsePtr response = 197 payments::mojom::blink::PaymentResponsePtr response =
194 mojom::blink::PaymentResponse::New(); 198 payments::mojom::blink::PaymentResponse::New();
195 response->payer_name = ""; 199 response->payer_name = "";
196 200
197 request->show(scope.getScriptState()) 201 request->show(scope.getScriptState())
198 .then(funcs.expectNoCall(), funcs.expectCall()); 202 .then(funcs.expectNoCall(), funcs.expectCall());
199 203
200 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 204 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
201 std::move(response)); 205 ->OnPaymentResponse(std::move(response));
202 } 206 }
203 207
204 // If the merchant requests an email, but the browser provides an empty string 208 // If the merchant requests an email, but the browser provides an empty string
205 // for email, reject the show() promise. 209 // for email, reject the show() promise.
206 TEST(OnPaymentResponseTest, RejectEmptyEmail) { 210 TEST(OnPaymentResponseTest, RejectEmptyEmail) {
207 V8TestingScope scope; 211 V8TestingScope scope;
208 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 212 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
209 makePaymentRequestOriginSecure(scope.document()); 213 makePaymentRequestOriginSecure(scope.document());
210 PaymentOptions options; 214 PaymentOptions options;
211 options.setRequestPayerEmail(true); 215 options.setRequestPayerEmail(true);
212 PaymentRequest* request = PaymentRequest::create( 216 PaymentRequest* request = PaymentRequest::create(
213 scope.getScriptState(), buildPaymentMethodDataForTest(), 217 scope.getScriptState(), buildPaymentMethodDataForTest(),
214 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 218 buildPaymentDetailsForTest(), options, scope.getExceptionState());
215 EXPECT_FALSE(scope.getExceptionState().hadException()); 219 EXPECT_FALSE(scope.getExceptionState().hadException());
216 mojom::blink::PaymentResponsePtr response = 220 payments::mojom::blink::PaymentResponsePtr response =
217 mojom::blink::PaymentResponse::New(); 221 payments::mojom::blink::PaymentResponse::New();
218 response->payer_email = ""; 222 response->payer_email = "";
219 223
220 request->show(scope.getScriptState()) 224 request->show(scope.getScriptState())
221 .then(funcs.expectNoCall(), funcs.expectCall()); 225 .then(funcs.expectNoCall(), funcs.expectCall());
222 226
223 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 227 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
224 std::move(response)); 228 ->OnPaymentResponse(std::move(response));
225 } 229 }
226 230
227 // If the merchant requests a phone number, but the browser provides an empty 231 // If the merchant requests a phone number, but the browser provides an empty
228 // string for the phone number, reject the show() promise. 232 // string for the phone number, reject the show() promise.
229 TEST(OnPaymentResponseTest, RejectEmptyPhone) { 233 TEST(OnPaymentResponseTest, RejectEmptyPhone) {
230 V8TestingScope scope; 234 V8TestingScope scope;
231 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 235 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
232 makePaymentRequestOriginSecure(scope.document()); 236 makePaymentRequestOriginSecure(scope.document());
233 PaymentOptions options; 237 PaymentOptions options;
234 options.setRequestPayerPhone(true); 238 options.setRequestPayerPhone(true);
235 PaymentRequest* request = PaymentRequest::create( 239 PaymentRequest* request = PaymentRequest::create(
236 scope.getScriptState(), buildPaymentMethodDataForTest(), 240 scope.getScriptState(), buildPaymentMethodDataForTest(),
237 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 241 buildPaymentDetailsForTest(), options, scope.getExceptionState());
238 EXPECT_FALSE(scope.getExceptionState().hadException()); 242 EXPECT_FALSE(scope.getExceptionState().hadException());
239 mojom::blink::PaymentResponsePtr response = 243 payments::mojom::blink::PaymentResponsePtr response =
240 mojom::blink::PaymentResponse::New(); 244 payments::mojom::blink::PaymentResponse::New();
241 response->payer_phone = ""; 245 response->payer_phone = "";
242 246
243 request->show(scope.getScriptState()) 247 request->show(scope.getScriptState())
244 .then(funcs.expectNoCall(), funcs.expectCall()); 248 .then(funcs.expectNoCall(), funcs.expectCall());
245 249
246 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 250 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
247 std::move(response)); 251 ->OnPaymentResponse(std::move(response));
248 } 252 }
249 253
250 // If the merchant does not request shipping information, but the browser 254 // If the merchant does not request shipping information, but the browser
251 // provides a shipping address, reject the show() promise. 255 // provides a shipping address, reject the show() promise.
252 TEST(OnPaymentResponseTest, RejectNotRequestedAddress) { 256 TEST(OnPaymentResponseTest, RejectNotRequestedAddress) {
253 V8TestingScope scope; 257 V8TestingScope scope;
254 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 258 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
255 makePaymentRequestOriginSecure(scope.document()); 259 makePaymentRequestOriginSecure(scope.document());
256 PaymentOptions options; 260 PaymentOptions options;
257 options.setRequestShipping(false); 261 options.setRequestShipping(false);
258 PaymentRequest* request = PaymentRequest::create( 262 PaymentRequest* request = PaymentRequest::create(
259 scope.getScriptState(), buildPaymentMethodDataForTest(), 263 scope.getScriptState(), buildPaymentMethodDataForTest(),
260 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 264 buildPaymentDetailsForTest(), options, scope.getExceptionState());
261 ASSERT_FALSE(scope.getExceptionState().hadException()); 265 ASSERT_FALSE(scope.getExceptionState().hadException());
262 mojom::blink::PaymentResponsePtr response = 266 payments::mojom::blink::PaymentResponsePtr response =
263 mojom::blink::PaymentResponse::New(); 267 payments::mojom::blink::PaymentResponse::New();
264 response->shipping_address = mojom::blink::PaymentAddress::New(); 268 response->shipping_address = payments::mojom::blink::PaymentAddress::New();
265 response->shipping_address->country = "US"; 269 response->shipping_address->country = "US";
266 response->shipping_address->language_code = "en"; 270 response->shipping_address->language_code = "en";
267 response->shipping_address->script_code = "Latn"; 271 response->shipping_address->script_code = "Latn";
268 272
269 request->show(scope.getScriptState()) 273 request->show(scope.getScriptState())
270 .then(funcs.expectNoCall(), funcs.expectCall()); 274 .then(funcs.expectNoCall(), funcs.expectCall());
271 275
272 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 276 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
273 std::move(response)); 277 ->OnPaymentResponse(std::move(response));
274 } 278 }
275 279
276 // If the merchant does not request shipping information, but the browser 280 // If the merchant does not request shipping information, but the browser
277 // provides a shipping option, reject the show() promise. 281 // provides a shipping option, reject the show() promise.
278 TEST(OnPaymentResponseTest, RejectNotRequestedShippingOption) { 282 TEST(OnPaymentResponseTest, RejectNotRequestedShippingOption) {
279 V8TestingScope scope; 283 V8TestingScope scope;
280 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 284 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
281 makePaymentRequestOriginSecure(scope.document()); 285 makePaymentRequestOriginSecure(scope.document());
282 PaymentOptions options; 286 PaymentOptions options;
283 options.setRequestShipping(false); 287 options.setRequestShipping(false);
284 PaymentRequest* request = PaymentRequest::create( 288 PaymentRequest* request = PaymentRequest::create(
285 scope.getScriptState(), buildPaymentMethodDataForTest(), 289 scope.getScriptState(), buildPaymentMethodDataForTest(),
286 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 290 buildPaymentDetailsForTest(), options, scope.getExceptionState());
287 ASSERT_FALSE(scope.getExceptionState().hadException()); 291 ASSERT_FALSE(scope.getExceptionState().hadException());
288 mojom::blink::PaymentResponsePtr response = 292 payments::mojom::blink::PaymentResponsePtr response =
289 mojom::blink::PaymentResponse::New(); 293 payments::mojom::blink::PaymentResponse::New();
290 response->shipping_option = ""; 294 response->shipping_option = "";
291 295
292 request->show(scope.getScriptState()) 296 request->show(scope.getScriptState())
293 .then(funcs.expectNoCall(), funcs.expectCall()); 297 .then(funcs.expectNoCall(), funcs.expectCall());
294 298
295 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 299 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
296 std::move(response)); 300 ->OnPaymentResponse(std::move(response));
297 } 301 }
298 302
299 // If the merchant does not request a payer name, but the browser provides it, 303 // If the merchant does not request a payer name, but the browser provides it,
300 // reject the show() promise. 304 // reject the show() promise.
301 TEST(OnPaymentResponseTest, RejectNotRequestedName) { 305 TEST(OnPaymentResponseTest, RejectNotRequestedName) {
302 V8TestingScope scope; 306 V8TestingScope scope;
303 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 307 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
304 makePaymentRequestOriginSecure(scope.document()); 308 makePaymentRequestOriginSecure(scope.document());
305 PaymentOptions options; 309 PaymentOptions options;
306 options.setRequestPayerName(false); 310 options.setRequestPayerName(false);
307 PaymentRequest* request = PaymentRequest::create( 311 PaymentRequest* request = PaymentRequest::create(
308 scope.getScriptState(), buildPaymentMethodDataForTest(), 312 scope.getScriptState(), buildPaymentMethodDataForTest(),
309 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 313 buildPaymentDetailsForTest(), options, scope.getExceptionState());
310 EXPECT_FALSE(scope.getExceptionState().hadException()); 314 EXPECT_FALSE(scope.getExceptionState().hadException());
311 mojom::blink::PaymentResponsePtr response = 315 payments::mojom::blink::PaymentResponsePtr response =
312 mojom::blink::PaymentResponse::New(); 316 payments::mojom::blink::PaymentResponse::New();
313 response->payer_name = ""; 317 response->payer_name = "";
314 318
315 request->show(scope.getScriptState()) 319 request->show(scope.getScriptState())
316 .then(funcs.expectNoCall(), funcs.expectCall()); 320 .then(funcs.expectNoCall(), funcs.expectCall());
317 321
318 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 322 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
319 std::move(response)); 323 ->OnPaymentResponse(std::move(response));
320 } 324 }
321 325
322 // If the merchant does not request an email, but the browser provides it, 326 // If the merchant does not request an email, but the browser provides it,
323 // reject the show() promise. 327 // reject the show() promise.
324 TEST(OnPaymentResponseTest, RejectNotRequestedEmail) { 328 TEST(OnPaymentResponseTest, RejectNotRequestedEmail) {
325 V8TestingScope scope; 329 V8TestingScope scope;
326 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 330 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
327 makePaymentRequestOriginSecure(scope.document()); 331 makePaymentRequestOriginSecure(scope.document());
328 PaymentOptions options; 332 PaymentOptions options;
329 options.setRequestPayerEmail(false); 333 options.setRequestPayerEmail(false);
330 PaymentRequest* request = PaymentRequest::create( 334 PaymentRequest* request = PaymentRequest::create(
331 scope.getScriptState(), buildPaymentMethodDataForTest(), 335 scope.getScriptState(), buildPaymentMethodDataForTest(),
332 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 336 buildPaymentDetailsForTest(), options, scope.getExceptionState());
333 EXPECT_FALSE(scope.getExceptionState().hadException()); 337 EXPECT_FALSE(scope.getExceptionState().hadException());
334 mojom::blink::PaymentResponsePtr response = 338 payments::mojom::blink::PaymentResponsePtr response =
335 mojom::blink::PaymentResponse::New(); 339 payments::mojom::blink::PaymentResponse::New();
336 response->payer_email = ""; 340 response->payer_email = "";
337 341
338 request->show(scope.getScriptState()) 342 request->show(scope.getScriptState())
339 .then(funcs.expectNoCall(), funcs.expectCall()); 343 .then(funcs.expectNoCall(), funcs.expectCall());
340 344
341 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 345 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
342 std::move(response)); 346 ->OnPaymentResponse(std::move(response));
343 } 347 }
344 348
345 // If the merchant does not request a phone number, but the browser provides it, 349 // If the merchant does not request a phone number, but the browser provides it,
346 // reject the show() promise. 350 // reject the show() promise.
347 TEST(OnPaymentResponseTest, RejectNotRequestedPhone) { 351 TEST(OnPaymentResponseTest, RejectNotRequestedPhone) {
348 V8TestingScope scope; 352 V8TestingScope scope;
349 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 353 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
350 makePaymentRequestOriginSecure(scope.document()); 354 makePaymentRequestOriginSecure(scope.document());
351 PaymentOptions options; 355 PaymentOptions options;
352 options.setRequestPayerPhone(false); 356 options.setRequestPayerPhone(false);
353 PaymentRequest* request = PaymentRequest::create( 357 PaymentRequest* request = PaymentRequest::create(
354 scope.getScriptState(), buildPaymentMethodDataForTest(), 358 scope.getScriptState(), buildPaymentMethodDataForTest(),
355 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 359 buildPaymentDetailsForTest(), options, scope.getExceptionState());
356 EXPECT_FALSE(scope.getExceptionState().hadException()); 360 EXPECT_FALSE(scope.getExceptionState().hadException());
357 mojom::blink::PaymentResponsePtr response = 361 payments::mojom::blink::PaymentResponsePtr response =
358 mojom::blink::PaymentResponse::New(); 362 payments::mojom::blink::PaymentResponse::New();
359 response->payer_phone = ""; 363 response->payer_phone = "";
360 364
361 request->show(scope.getScriptState()) 365 request->show(scope.getScriptState())
362 .then(funcs.expectNoCall(), funcs.expectCall()); 366 .then(funcs.expectNoCall(), funcs.expectCall());
363 367
364 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 368 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
365 std::move(response)); 369 ->OnPaymentResponse(std::move(response));
366 } 370 }
367 371
368 // If the merchant requests shipping information, but the browser provides an 372 // If the merchant requests shipping information, but the browser provides an
369 // invalid shipping address, reject the show() promise. 373 // invalid shipping address, reject the show() promise.
370 TEST(OnPaymentResponseTest, RejectInvalidAddress) { 374 TEST(OnPaymentResponseTest, RejectInvalidAddress) {
371 V8TestingScope scope; 375 V8TestingScope scope;
372 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 376 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
373 makePaymentRequestOriginSecure(scope.document()); 377 makePaymentRequestOriginSecure(scope.document());
374 PaymentOptions options; 378 PaymentOptions options;
375 options.setRequestShipping(true); 379 options.setRequestShipping(true);
376 PaymentRequest* request = PaymentRequest::create( 380 PaymentRequest* request = PaymentRequest::create(
377 scope.getScriptState(), buildPaymentMethodDataForTest(), 381 scope.getScriptState(), buildPaymentMethodDataForTest(),
378 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 382 buildPaymentDetailsForTest(), options, scope.getExceptionState());
379 ASSERT_FALSE(scope.getExceptionState().hadException()); 383 ASSERT_FALSE(scope.getExceptionState().hadException());
380 mojom::blink::PaymentResponsePtr response = buildPaymentResponseForTest(); 384 payments::mojom::blink::PaymentResponsePtr response =
385 buildPaymentResponseForTest();
381 response->shipping_option = "standardShipping"; 386 response->shipping_option = "standardShipping";
382 response->shipping_address = mojom::blink::PaymentAddress::New(); 387 response->shipping_address = payments::mojom::blink::PaymentAddress::New();
383 response->shipping_address->country = "Atlantis"; 388 response->shipping_address->country = "Atlantis";
384 389
385 request->show(scope.getScriptState()) 390 request->show(scope.getScriptState())
386 .then(funcs.expectNoCall(), funcs.expectCall()); 391 .then(funcs.expectNoCall(), funcs.expectCall());
387 392
388 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 393 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
389 std::move(response)); 394 ->OnPaymentResponse(std::move(response));
390 } 395 }
391 396
392 class PaymentResponseFunction : public ScriptFunction { 397 class PaymentResponseFunction : public ScriptFunction {
393 public: 398 public:
394 static v8::Local<v8::Function> create(ScriptState* scriptState, 399 static v8::Local<v8::Function> create(ScriptState* scriptState,
395 ScriptValue* outValue) { 400 ScriptValue* outValue) {
396 PaymentResponseFunction* self = 401 PaymentResponseFunction* self =
397 new PaymentResponseFunction(scriptState, outValue); 402 new PaymentResponseFunction(scriptState, outValue);
398 return self->bindToV8Function(); 403 return self->bindToV8Function();
399 } 404 }
(...skipping 18 matching lines...) Expand all
418 TEST(OnPaymentResponseTest, CanRequestShippingInformation) { 423 TEST(OnPaymentResponseTest, CanRequestShippingInformation) {
419 V8TestingScope scope; 424 V8TestingScope scope;
420 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 425 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
421 makePaymentRequestOriginSecure(scope.document()); 426 makePaymentRequestOriginSecure(scope.document());
422 PaymentOptions options; 427 PaymentOptions options;
423 options.setRequestShipping(true); 428 options.setRequestShipping(true);
424 PaymentRequest* request = PaymentRequest::create( 429 PaymentRequest* request = PaymentRequest::create(
425 scope.getScriptState(), buildPaymentMethodDataForTest(), 430 scope.getScriptState(), buildPaymentMethodDataForTest(),
426 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 431 buildPaymentDetailsForTest(), options, scope.getExceptionState());
427 ASSERT_FALSE(scope.getExceptionState().hadException()); 432 ASSERT_FALSE(scope.getExceptionState().hadException());
428 mojom::blink::PaymentResponsePtr response = buildPaymentResponseForTest(); 433 payments::mojom::blink::PaymentResponsePtr response =
434 buildPaymentResponseForTest();
429 response->shipping_option = "standardShipping"; 435 response->shipping_option = "standardShipping";
430 response->shipping_address = mojom::blink::PaymentAddress::New(); 436 response->shipping_address = payments::mojom::blink::PaymentAddress::New();
431 response->shipping_address->country = "US"; 437 response->shipping_address->country = "US";
432 response->shipping_address->language_code = "en"; 438 response->shipping_address->language_code = "en";
433 response->shipping_address->script_code = "Latn"; 439 response->shipping_address->script_code = "Latn";
434 ScriptValue outValue; 440 ScriptValue outValue;
435 request->show(scope.getScriptState()) 441 request->show(scope.getScriptState())
436 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 442 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
437 funcs.expectNoCall()); 443 funcs.expectNoCall());
438 444
439 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 445 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
440 std::move(response)); 446 ->OnPaymentResponse(std::move(response));
441 447
442 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 448 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
443 PaymentResponse* resp = V8PaymentResponse::toImplWithTypeCheck( 449 PaymentResponse* resp = V8PaymentResponse::toImplWithTypeCheck(
444 scope.isolate(), outValue.v8Value()); 450 scope.isolate(), outValue.v8Value());
445 EXPECT_EQ("standardShipping", resp->shippingOption()); 451 EXPECT_EQ("standardShipping", resp->shippingOption());
446 EXPECT_EQ("US", resp->shippingAddress()->country()); 452 EXPECT_EQ("US", resp->shippingAddress()->country());
447 EXPECT_EQ("en-Latn", resp->shippingAddress()->languageCode()); 453 EXPECT_EQ("en-Latn", resp->shippingAddress()->languageCode());
448 } 454 }
449 455
450 // If the merchant requests a payer name, the resolved show() promise should 456 // If the merchant requests a payer name, the resolved show() promise should
451 // contain a payer name. 457 // contain a payer name.
452 TEST(OnPaymentResponseTest, CanRequestName) { 458 TEST(OnPaymentResponseTest, CanRequestName) {
453 V8TestingScope scope; 459 V8TestingScope scope;
454 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 460 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
455 makePaymentRequestOriginSecure(scope.document()); 461 makePaymentRequestOriginSecure(scope.document());
456 PaymentOptions options; 462 PaymentOptions options;
457 options.setRequestPayerName(true); 463 options.setRequestPayerName(true);
458 PaymentRequest* request = PaymentRequest::create( 464 PaymentRequest* request = PaymentRequest::create(
459 scope.getScriptState(), buildPaymentMethodDataForTest(), 465 scope.getScriptState(), buildPaymentMethodDataForTest(),
460 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 466 buildPaymentDetailsForTest(), options, scope.getExceptionState());
461 EXPECT_FALSE(scope.getExceptionState().hadException()); 467 EXPECT_FALSE(scope.getExceptionState().hadException());
462 mojom::blink::PaymentResponsePtr response = 468 payments::mojom::blink::PaymentResponsePtr response =
463 mojom::blink::PaymentResponse::New(); 469 payments::mojom::blink::PaymentResponse::New();
464 response->payer_name = "Jon Doe"; 470 response->payer_name = "Jon Doe";
465 ScriptValue outValue; 471 ScriptValue outValue;
466 request->show(scope.getScriptState()) 472 request->show(scope.getScriptState())
467 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 473 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
468 funcs.expectNoCall()); 474 funcs.expectNoCall());
469 475
470 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 476 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
471 std::move(response)); 477 ->OnPaymentResponse(std::move(response));
472 478
473 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 479 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
474 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck( 480 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(
475 scope.isolate(), outValue.v8Value()); 481 scope.isolate(), outValue.v8Value());
476 EXPECT_EQ("Jon Doe", pr->payerName()); 482 EXPECT_EQ("Jon Doe", pr->payerName());
477 } 483 }
478 484
479 // If the merchant requests an email address, the resolved show() promise should 485 // If the merchant requests an email address, the resolved show() promise should
480 // contain an email address. 486 // contain an email address.
481 TEST(OnPaymentResponseTest, CanRequestEmail) { 487 TEST(OnPaymentResponseTest, CanRequestEmail) {
482 V8TestingScope scope; 488 V8TestingScope scope;
483 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 489 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
484 makePaymentRequestOriginSecure(scope.document()); 490 makePaymentRequestOriginSecure(scope.document());
485 PaymentOptions options; 491 PaymentOptions options;
486 options.setRequestPayerEmail(true); 492 options.setRequestPayerEmail(true);
487 PaymentRequest* request = PaymentRequest::create( 493 PaymentRequest* request = PaymentRequest::create(
488 scope.getScriptState(), buildPaymentMethodDataForTest(), 494 scope.getScriptState(), buildPaymentMethodDataForTest(),
489 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 495 buildPaymentDetailsForTest(), options, scope.getExceptionState());
490 EXPECT_FALSE(scope.getExceptionState().hadException()); 496 EXPECT_FALSE(scope.getExceptionState().hadException());
491 mojom::blink::PaymentResponsePtr response = 497 payments::mojom::blink::PaymentResponsePtr response =
492 mojom::blink::PaymentResponse::New(); 498 payments::mojom::blink::PaymentResponse::New();
493 response->payer_email = "abc@gmail.com"; 499 response->payer_email = "abc@gmail.com";
494 ScriptValue outValue; 500 ScriptValue outValue;
495 request->show(scope.getScriptState()) 501 request->show(scope.getScriptState())
496 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 502 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
497 funcs.expectNoCall()); 503 funcs.expectNoCall());
498 504
499 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 505 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
500 std::move(response)); 506 ->OnPaymentResponse(std::move(response));
501 507
502 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 508 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
503 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck( 509 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(
504 scope.isolate(), outValue.v8Value()); 510 scope.isolate(), outValue.v8Value());
505 EXPECT_EQ("abc@gmail.com", pr->payerEmail()); 511 EXPECT_EQ("abc@gmail.com", pr->payerEmail());
506 } 512 }
507 513
508 // If the merchant requests a phone number, the resolved show() promise should 514 // If the merchant requests a phone number, the resolved show() promise should
509 // contain a phone number. 515 // contain a phone number.
510 TEST(OnPaymentResponseTest, CanRequestPhone) { 516 TEST(OnPaymentResponseTest, CanRequestPhone) {
511 V8TestingScope scope; 517 V8TestingScope scope;
512 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 518 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
513 makePaymentRequestOriginSecure(scope.document()); 519 makePaymentRequestOriginSecure(scope.document());
514 PaymentOptions options; 520 PaymentOptions options;
515 options.setRequestPayerPhone(true); 521 options.setRequestPayerPhone(true);
516 PaymentRequest* request = PaymentRequest::create( 522 PaymentRequest* request = PaymentRequest::create(
517 scope.getScriptState(), buildPaymentMethodDataForTest(), 523 scope.getScriptState(), buildPaymentMethodDataForTest(),
518 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 524 buildPaymentDetailsForTest(), options, scope.getExceptionState());
519 EXPECT_FALSE(scope.getExceptionState().hadException()); 525 EXPECT_FALSE(scope.getExceptionState().hadException());
520 mojom::blink::PaymentResponsePtr response = 526 payments::mojom::blink::PaymentResponsePtr response =
521 mojom::blink::PaymentResponse::New(); 527 payments::mojom::blink::PaymentResponse::New();
522 response->payer_phone = "0123"; 528 response->payer_phone = "0123";
523 529
524 ScriptValue outValue; 530 ScriptValue outValue;
525 request->show(scope.getScriptState()) 531 request->show(scope.getScriptState())
526 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 532 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
527 funcs.expectNoCall()); 533 funcs.expectNoCall());
528 534
529 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 535 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
530 std::move(response)); 536 ->OnPaymentResponse(std::move(response));
531 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 537 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
532 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck( 538 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(
533 scope.isolate(), outValue.v8Value()); 539 scope.isolate(), outValue.v8Value());
534 540
535 EXPECT_EQ("0123", pr->payerPhone()); 541 EXPECT_EQ("0123", pr->payerPhone());
536 } 542 }
537 543
538 // If the merchant does not request shipping information, the resolved show() 544 // If the merchant does not request shipping information, the resolved show()
539 // promise should contain null shipping option and address. 545 // promise should contain null shipping option and address.
540 TEST(OnPaymentResponseTest, ShippingInformationNotRequired) { 546 TEST(OnPaymentResponseTest, ShippingInformationNotRequired) {
541 V8TestingScope scope; 547 V8TestingScope scope;
542 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 548 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
543 makePaymentRequestOriginSecure(scope.document()); 549 makePaymentRequestOriginSecure(scope.document());
544 PaymentOptions options; 550 PaymentOptions options;
545 options.setRequestShipping(false); 551 options.setRequestShipping(false);
546 PaymentRequest* request = PaymentRequest::create( 552 PaymentRequest* request = PaymentRequest::create(
547 scope.getScriptState(), buildPaymentMethodDataForTest(), 553 scope.getScriptState(), buildPaymentMethodDataForTest(),
548 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 554 buildPaymentDetailsForTest(), options, scope.getExceptionState());
549 ASSERT_FALSE(scope.getExceptionState().hadException()); 555 ASSERT_FALSE(scope.getExceptionState().hadException());
550 ScriptValue outValue; 556 ScriptValue outValue;
551 request->show(scope.getScriptState()) 557 request->show(scope.getScriptState())
552 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 558 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
553 funcs.expectNoCall()); 559 funcs.expectNoCall());
554 560
555 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 561 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
556 buildPaymentResponseForTest()); 562 ->OnPaymentResponse(buildPaymentResponseForTest());
557 563
558 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 564 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
559 PaymentResponse* resp = V8PaymentResponse::toImplWithTypeCheck( 565 PaymentResponse* resp = V8PaymentResponse::toImplWithTypeCheck(
560 scope.isolate(), outValue.v8Value()); 566 scope.isolate(), outValue.v8Value());
561 EXPECT_TRUE(resp->shippingOption().isNull()); 567 EXPECT_TRUE(resp->shippingOption().isNull());
562 EXPECT_EQ(nullptr, resp->shippingAddress()); 568 EXPECT_EQ(nullptr, resp->shippingAddress());
563 } 569 }
564 570
565 // If the merchant does not request a phone number, the resolved show() promise 571 // If the merchant does not request a phone number, the resolved show() promise
566 // should contain null phone number. 572 // should contain null phone number.
567 TEST(OnPaymentResponseTest, PhoneNotRequred) { 573 TEST(OnPaymentResponseTest, PhoneNotRequred) {
568 V8TestingScope scope; 574 V8TestingScope scope;
569 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 575 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
570 makePaymentRequestOriginSecure(scope.document()); 576 makePaymentRequestOriginSecure(scope.document());
571 PaymentOptions options; 577 PaymentOptions options;
572 options.setRequestPayerPhone(false); 578 options.setRequestPayerPhone(false);
573 PaymentRequest* request = PaymentRequest::create( 579 PaymentRequest* request = PaymentRequest::create(
574 scope.getScriptState(), buildPaymentMethodDataForTest(), 580 scope.getScriptState(), buildPaymentMethodDataForTest(),
575 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 581 buildPaymentDetailsForTest(), options, scope.getExceptionState());
576 EXPECT_FALSE(scope.getExceptionState().hadException()); 582 EXPECT_FALSE(scope.getExceptionState().hadException());
577 mojom::blink::PaymentResponsePtr response = 583 payments::mojom::blink::PaymentResponsePtr response =
578 mojom::blink::PaymentResponse::New(); 584 payments::mojom::blink::PaymentResponse::New();
579 response->payer_phone = String(); 585 response->payer_phone = String();
580 ScriptValue outValue; 586 ScriptValue outValue;
581 request->show(scope.getScriptState()) 587 request->show(scope.getScriptState())
582 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 588 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
583 funcs.expectNoCall()); 589 funcs.expectNoCall());
584 590
585 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 591 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
586 std::move(response)); 592 ->OnPaymentResponse(std::move(response));
587 593
588 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 594 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
589 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck( 595 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(
590 scope.isolate(), outValue.v8Value()); 596 scope.isolate(), outValue.v8Value());
591 EXPECT_TRUE(pr->payerPhone().isNull()); 597 EXPECT_TRUE(pr->payerPhone().isNull());
592 } 598 }
593 599
594 // If the merchant does not request a payer name, the resolved show() promise 600 // If the merchant does not request a payer name, the resolved show() promise
595 // should contain null payer name. 601 // should contain null payer name.
596 TEST(OnPaymentResponseTest, NameNotRequired) { 602 TEST(OnPaymentResponseTest, NameNotRequired) {
597 V8TestingScope scope; 603 V8TestingScope scope;
598 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 604 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
599 makePaymentRequestOriginSecure(scope.document()); 605 makePaymentRequestOriginSecure(scope.document());
600 PaymentOptions options; 606 PaymentOptions options;
601 options.setRequestPayerName(false); 607 options.setRequestPayerName(false);
602 PaymentRequest* request = PaymentRequest::create( 608 PaymentRequest* request = PaymentRequest::create(
603 scope.getScriptState(), buildPaymentMethodDataForTest(), 609 scope.getScriptState(), buildPaymentMethodDataForTest(),
604 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 610 buildPaymentDetailsForTest(), options, scope.getExceptionState());
605 EXPECT_FALSE(scope.getExceptionState().hadException()); 611 EXPECT_FALSE(scope.getExceptionState().hadException());
606 mojom::blink::PaymentResponsePtr response = 612 payments::mojom::blink::PaymentResponsePtr response =
607 mojom::blink::PaymentResponse::New(); 613 payments::mojom::blink::PaymentResponse::New();
608 response->payer_name = String(); 614 response->payer_name = String();
609 ScriptValue outValue; 615 ScriptValue outValue;
610 request->show(scope.getScriptState()) 616 request->show(scope.getScriptState())
611 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 617 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
612 funcs.expectNoCall()); 618 funcs.expectNoCall());
613 619
614 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 620 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
615 std::move(response)); 621 ->OnPaymentResponse(std::move(response));
616 622
617 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 623 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
618 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck( 624 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(
619 scope.isolate(), outValue.v8Value()); 625 scope.isolate(), outValue.v8Value());
620 EXPECT_TRUE(pr->payerName().isNull()); 626 EXPECT_TRUE(pr->payerName().isNull());
621 } 627 }
622 628
623 // If the merchant does not request an email address, the resolved show() 629 // If the merchant does not request an email address, the resolved show()
624 // promise should contain null email address. 630 // promise should contain null email address.
625 TEST(OnPaymentResponseTest, EmailNotRequired) { 631 TEST(OnPaymentResponseTest, EmailNotRequired) {
626 V8TestingScope scope; 632 V8TestingScope scope;
627 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); 633 PaymentRequestMockFunctionScope funcs(scope.getScriptState());
628 makePaymentRequestOriginSecure(scope.document()); 634 makePaymentRequestOriginSecure(scope.document());
629 PaymentOptions options; 635 PaymentOptions options;
630 options.setRequestPayerEmail(false); 636 options.setRequestPayerEmail(false);
631 PaymentRequest* request = PaymentRequest::create( 637 PaymentRequest* request = PaymentRequest::create(
632 scope.getScriptState(), buildPaymentMethodDataForTest(), 638 scope.getScriptState(), buildPaymentMethodDataForTest(),
633 buildPaymentDetailsForTest(), options, scope.getExceptionState()); 639 buildPaymentDetailsForTest(), options, scope.getExceptionState());
634 EXPECT_FALSE(scope.getExceptionState().hadException()); 640 EXPECT_FALSE(scope.getExceptionState().hadException());
635 mojom::blink::PaymentResponsePtr response = 641 payments::mojom::blink::PaymentResponsePtr response =
636 mojom::blink::PaymentResponse::New(); 642 payments::mojom::blink::PaymentResponse::New();
637 response->payer_email = String(); 643 response->payer_email = String();
638 ScriptValue outValue; 644 ScriptValue outValue;
639 request->show(scope.getScriptState()) 645 request->show(scope.getScriptState())
640 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue), 646 .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
641 funcs.expectNoCall()); 647 funcs.expectNoCall());
642 648
643 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse( 649 static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
644 std::move(response)); 650 ->OnPaymentResponse(std::move(response));
645 651
646 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); 652 v8::MicrotasksScope::PerformCheckpoint(scope.isolate());
647 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck( 653 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(
648 scope.isolate(), outValue.v8Value()); 654 scope.isolate(), outValue.v8Value());
649 EXPECT_TRUE(pr->payerEmail().isNull()); 655 EXPECT_TRUE(pr->payerEmail().isNull());
650 } 656 }
651 657
652 } // namespace 658 } // namespace
653 } // namespace blink 659 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698