| 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::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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 TEST(PaymentRequestTest, RejectMissingEmail) | 62 TEST(PaymentRequestTest, RejectMissingEmail) |
| 63 { | 63 { |
| 64 V8TestingScope scope; | 64 V8TestingScope scope; |
| 65 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 65 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 66 makePaymentRequestOriginSecure(scope.document()); | 66 makePaymentRequestOriginSecure(scope.document()); |
| 67 PaymentOptions options; | 67 PaymentOptions options; |
| 68 options.setRequestPayerEmail(true); | 68 options.setRequestPayerEmail(true); |
| 69 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 69 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 70 EXPECT_FALSE(scope.getExceptionState().hadException()); | 70 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 71 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 71 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 72 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 73 | 72 |
| 74 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); | 73 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); |
| 75 | 74 |
| 76 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 75 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 77 } | 76 } |
| 78 | 77 |
| 79 // If the merchant requests a phone number, but the browser does not provide it, | 78 // If the merchant requests a phone number, but the browser does not provide it, |
| 80 // reject the show() promise. | 79 // reject the show() promise. |
| 81 TEST(PaymentRequestTest, RejectMissingPhone) | 80 TEST(PaymentRequestTest, RejectMissingPhone) |
| 82 { | 81 { |
| 83 V8TestingScope scope; | 82 V8TestingScope scope; |
| 84 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 83 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 85 makePaymentRequestOriginSecure(scope.document()); | 84 makePaymentRequestOriginSecure(scope.document()); |
| 86 PaymentOptions options; | 85 PaymentOptions options; |
| 87 options.setRequestPayerPhone(true); | 86 options.setRequestPayerPhone(true); |
| 88 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 87 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 89 EXPECT_FALSE(scope.getExceptionState().hadException()); | 88 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 90 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 89 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 91 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 92 | 90 |
| 93 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); | 91 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); |
| 94 | 92 |
| 95 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 93 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 96 } | 94 } |
| 97 | 95 |
| 98 // If the merchant requests shipping information, but the browser provides an | 96 // If the merchant requests shipping information, but the browser provides an |
| 99 // empty string for shipping option, reject the show() promise. | 97 // empty string for shipping option, reject the show() promise. |
| 100 TEST(OnPaymentResponseTest, RejectEmptyShippingOption) | 98 TEST(OnPaymentResponseTest, RejectEmptyShippingOption) |
| 101 { | 99 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 TEST(PaymentRequestTest, RejectEmptyEmail) | 141 TEST(PaymentRequestTest, RejectEmptyEmail) |
| 144 { | 142 { |
| 145 V8TestingScope scope; | 143 V8TestingScope scope; |
| 146 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 144 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 147 makePaymentRequestOriginSecure(scope.document()); | 145 makePaymentRequestOriginSecure(scope.document()); |
| 148 PaymentOptions options; | 146 PaymentOptions options; |
| 149 options.setRequestPayerEmail(true); | 147 options.setRequestPayerEmail(true); |
| 150 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 148 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 151 EXPECT_FALSE(scope.getExceptionState().hadException()); | 149 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 152 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 150 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 153 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 154 response->payer_email = ""; | 151 response->payer_email = ""; |
| 155 | 152 |
| 156 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); | 153 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); |
| 157 | 154 |
| 158 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 155 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 159 } | 156 } |
| 160 | 157 |
| 161 // If the merchant requests a phone number, but the browser provides an empty | 158 // If the merchant requests a phone number, but the browser provides an empty |
| 162 // string for the phone number, reject the show() promise. | 159 // string for the phone number, reject the show() promise. |
| 163 TEST(PaymentRequestTest, RejectEmptyPhone) | 160 TEST(PaymentRequestTest, RejectEmptyPhone) |
| 164 { | 161 { |
| 165 V8TestingScope scope; | 162 V8TestingScope scope; |
| 166 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 163 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 167 makePaymentRequestOriginSecure(scope.document()); | 164 makePaymentRequestOriginSecure(scope.document()); |
| 168 PaymentOptions options; | 165 PaymentOptions options; |
| 169 options.setRequestPayerPhone(true); | 166 options.setRequestPayerPhone(true); |
| 170 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 167 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 171 EXPECT_FALSE(scope.getExceptionState().hadException()); | 168 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 172 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 169 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 173 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 174 response->payer_phone = ""; | 170 response->payer_phone = ""; |
| 175 | 171 |
| 176 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); | 172 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); |
| 177 | 173 |
| 178 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 174 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 179 } | 175 } |
| 180 | 176 |
| 181 // If the merchant does not request shipping information, but the browser | 177 // If the merchant does not request shipping information, but the browser |
| 182 // provides a shipping address, reject the show() promise. | 178 // provides a shipping address, reject the show() promise. |
| 183 TEST(OnPaymentResponseTest, RejectNotRequestedAddress) | 179 TEST(OnPaymentResponseTest, RejectNotRequestedAddress) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 TEST(PaymentRequestTest, RejectNotRequestedEmail) | 220 TEST(PaymentRequestTest, RejectNotRequestedEmail) |
| 225 { | 221 { |
| 226 V8TestingScope scope; | 222 V8TestingScope scope; |
| 227 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 223 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 228 makePaymentRequestOriginSecure(scope.document()); | 224 makePaymentRequestOriginSecure(scope.document()); |
| 229 PaymentOptions options; | 225 PaymentOptions options; |
| 230 options.setRequestPayerEmail(false); | 226 options.setRequestPayerEmail(false); |
| 231 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 227 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 232 EXPECT_FALSE(scope.getExceptionState().hadException()); | 228 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 233 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 229 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 234 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 235 response->payer_email = ""; | 230 response->payer_email = ""; |
| 236 | 231 |
| 237 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); | 232 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); |
| 238 | 233 |
| 239 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 234 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 240 } | 235 } |
| 241 | 236 |
| 242 // If the merchant does not request a phone number, but the browser provides it, | 237 // If the merchant does not request a phone number, but the browser provides it, |
| 243 // reject the show() promise. | 238 // reject the show() promise. |
| 244 TEST(PaymentRequestTest, RejectNotRequestedPhone) | 239 TEST(PaymentRequestTest, RejectNotRequestedPhone) |
| 245 { | 240 { |
| 246 V8TestingScope scope; | 241 V8TestingScope scope; |
| 247 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 242 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 248 makePaymentRequestOriginSecure(scope.document()); | 243 makePaymentRequestOriginSecure(scope.document()); |
| 249 PaymentOptions options; | 244 PaymentOptions options; |
| 250 options.setRequestPayerPhone(false); | 245 options.setRequestPayerPhone(false); |
| 251 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 246 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 252 EXPECT_FALSE(scope.getExceptionState().hadException()); | 247 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 253 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 248 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 254 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 255 response->payer_phone = ""; | 249 response->payer_phone = ""; |
| 256 | 250 |
| 257 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); | 251 request->show(scope.getScriptState()).then(funcs.expectNoCall(), funcs.expec
tCall()); |
| 258 | 252 |
| 259 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 253 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 260 } | 254 } |
| 261 | 255 |
| 262 // If the merchant requests shipping information, but the browser provides an | 256 // If the merchant requests shipping information, but the browser provides an |
| 263 // invalid shipping address, reject the show() promise. | 257 // invalid shipping address, reject the show() promise. |
| 264 TEST(OnPaymentResponseTest, RejectInvalidAddress) | 258 TEST(OnPaymentResponseTest, RejectInvalidAddress) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 TEST(PaymentRequestTest, CanRequestEmail) | 334 TEST(PaymentRequestTest, CanRequestEmail) |
| 341 { | 335 { |
| 342 V8TestingScope scope; | 336 V8TestingScope scope; |
| 343 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 337 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 344 makePaymentRequestOriginSecure(scope.document()); | 338 makePaymentRequestOriginSecure(scope.document()); |
| 345 PaymentOptions options; | 339 PaymentOptions options; |
| 346 options.setRequestPayerEmail(true); | 340 options.setRequestPayerEmail(true); |
| 347 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 341 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 348 EXPECT_FALSE(scope.getExceptionState().hadException()); | 342 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 349 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 343 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 350 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 351 response->payer_email = "abc@gmail.com"; | 344 response->payer_email = "abc@gmail.com"; |
| 352 ScriptValue outValue; | 345 ScriptValue outValue; |
| 353 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); | 346 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); |
| 354 | 347 |
| 355 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 348 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 356 | 349 |
| 357 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 350 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 358 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); | 351 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); |
| 359 EXPECT_EQ("abc@gmail.com", pr->payerEmail()); | 352 EXPECT_EQ("abc@gmail.com", pr->payerEmail()); |
| 360 } | 353 } |
| 361 | 354 |
| 362 // If the merchant requests a phone number, the resolved show() promise should | 355 // If the merchant requests a phone number, the resolved show() promise should |
| 363 // contain a phone number. | 356 // contain a phone number. |
| 364 TEST(PaymentRequestTest, CanRequestPhone) | 357 TEST(PaymentRequestTest, CanRequestPhone) |
| 365 { | 358 { |
| 366 V8TestingScope scope; | 359 V8TestingScope scope; |
| 367 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 360 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 368 makePaymentRequestOriginSecure(scope.document()); | 361 makePaymentRequestOriginSecure(scope.document()); |
| 369 PaymentOptions options; | 362 PaymentOptions options; |
| 370 options.setRequestPayerPhone(true); | 363 options.setRequestPayerPhone(true); |
| 371 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 364 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 372 EXPECT_FALSE(scope.getExceptionState().hadException()); | 365 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 373 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 366 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 374 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 375 response->payer_phone = "0123"; | 367 response->payer_phone = "0123"; |
| 376 | 368 |
| 377 ScriptValue outValue; | 369 ScriptValue outValue; |
| 378 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); | 370 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); |
| 379 | 371 |
| 380 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 372 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 381 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 373 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 382 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); | 374 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); |
| 383 | 375 |
| 384 EXPECT_EQ("0123", pr->payerPhone()); | 376 EXPECT_EQ("0123", pr->payerPhone()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 411 TEST(PaymentRequestTest, PhoneNotRequred) | 403 TEST(PaymentRequestTest, PhoneNotRequred) |
| 412 { | 404 { |
| 413 V8TestingScope scope; | 405 V8TestingScope scope; |
| 414 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 406 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 415 makePaymentRequestOriginSecure(scope.document()); | 407 makePaymentRequestOriginSecure(scope.document()); |
| 416 PaymentOptions options; | 408 PaymentOptions options; |
| 417 options.setRequestPayerPhone(false); | 409 options.setRequestPayerPhone(false); |
| 418 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 410 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 419 EXPECT_FALSE(scope.getExceptionState().hadException()); | 411 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 420 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 412 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 421 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 422 response->payer_phone = String(); | 413 response->payer_phone = String(); |
| 423 ScriptValue outValue; | 414 ScriptValue outValue; |
| 424 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); | 415 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); |
| 425 | 416 |
| 426 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 417 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 427 | 418 |
| 428 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 419 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 429 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); | 420 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); |
| 430 EXPECT_TRUE(pr->payerPhone().isNull()); | 421 EXPECT_TRUE(pr->payerPhone().isNull()); |
| 431 } | 422 } |
| 432 | 423 |
| 433 // If the merchant does not request an email address, the resolved show() | 424 // If the merchant does not request an email address, the resolved show() |
| 434 // promise should contain null email address. | 425 // promise should contain null email address. |
| 435 TEST(PaymentRequestTest, EmailNotRequired) | 426 TEST(PaymentRequestTest, EmailNotRequired) |
| 436 { | 427 { |
| 437 V8TestingScope scope; | 428 V8TestingScope scope; |
| 438 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); | 429 PaymentRequestMockFunctionScope funcs(scope.getScriptState()); |
| 439 makePaymentRequestOriginSecure(scope.document()); | 430 makePaymentRequestOriginSecure(scope.document()); |
| 440 PaymentOptions options; | 431 PaymentOptions options; |
| 441 options.setRequestPayerEmail(false); | 432 options.setRequestPayerEmail(false); |
| 442 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); | 433 PaymentRequest* request = PaymentRequest::create(scope.getScriptState(), bui
ldPaymentMethodDataForTest(), buildPaymentDetailsForTest(), options, scope.getEx
ceptionState()); |
| 443 EXPECT_FALSE(scope.getExceptionState().hadException()); | 434 EXPECT_FALSE(scope.getExceptionState().hadException()); |
| 444 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); | 435 mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::N
ew(); |
| 445 response->total_amount = mojom::blink::PaymentCurrencyAmount::New(); | |
| 446 response->payer_email = String(); | 436 response->payer_email = String(); |
| 447 ScriptValue outValue; | 437 ScriptValue outValue; |
| 448 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); | 438 request->show(scope.getScriptState()).then(PaymentResponseFunction::create(s
cope.getScriptState(), &outValue), funcs.expectNoCall()); |
| 449 | 439 |
| 450 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); | 440 static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse
(std::move(response)); |
| 451 | 441 |
| 452 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); | 442 v8::MicrotasksScope::PerformCheckpoint(scope.isolate()); |
| 453 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); | 443 PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(scope.isolate()
, outValue.v8Value()); |
| 454 EXPECT_TRUE(pr->payerEmail().isNull()); | 444 EXPECT_TRUE(pr->payerEmail().isNull()); |
| 455 } | 445 } |
| 456 | 446 |
| 457 } // namespace | 447 } // namespace |
| 458 } // namespace blink | 448 } // namespace blink |
| OLD | NEW |