| Index: third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
|
| diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
|
| index bc9af1a275f4aaa67d1e7b83e3573fbc680bd556..6fa443a236cd4331935081df76e1a212e0e35ada 100644
|
| --- a/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
|
| +++ b/third_party/WebKit/Source/modules/payments/PaymentRequestTest.cpp
|
| @@ -507,5 +507,184 @@ TEST_F(PaymentRequestTest, UseTheSingleShippingOptionFromPaymentDetailsUpdate)
|
| EXPECT_EQ("standardShippingOption", request->shippingOption());
|
| }
|
|
|
| +TEST_F(PaymentRequestTest, ResolveShowPromiseWithRequestPayerEmailTrueAndValidPayerEmailInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerEmail(true);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_email = "abc@gmail.com";
|
| +
|
| + ScriptValue outValue;
|
| + request->show(getScriptState()).then(PaymentResponseFunction::create(getScriptState(), &outValue), MockFunction::expectNoCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| + v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
|
| + PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(getScriptState()->isolate(), outValue.v8Value());
|
| +
|
| + EXPECT_EQ("abc@gmail.com", pr->payerEmail());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, RejectShowPromiseWithRequestPayerEmailTrueAndEmptyPayerEmailInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerEmail(true);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_email = "";
|
| +
|
| + request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptState()), MockFunction::expectCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, RejectShowPromiseWithRequestPayerEmailTrueAndNullPayerEmailInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerEmail(true);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_email = String();
|
| +
|
| + request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptState()), MockFunction::expectCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, ResolveShowPromiseWithRequestPayerEmailFalseAndEmptyPayerEmailInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerEmail(false);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_email = "";
|
| +
|
| + ScriptValue outValue;
|
| + request->show(getScriptState()).then(PaymentResponseFunction::create(getScriptState(), &outValue), MockFunction::expectNoCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| + v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
|
| + PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(getScriptState()->isolate(), outValue.v8Value());
|
| +
|
| + EXPECT_TRUE(pr->payerEmail().isNull());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, ResolveShowPromiseWithRequestPayerEmailFalseAndNullPayerEmailInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerEmail(false);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_email = String();
|
| +
|
| + ScriptValue outValue;
|
| + request->show(getScriptState()).then(PaymentResponseFunction::create(getScriptState(), &outValue), MockFunction::expectNoCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| + v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
|
| + PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(getScriptState()->isolate(), outValue.v8Value());
|
| +
|
| + EXPECT_TRUE(pr->payerEmail().isNull());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, ResolveShowPromiseWithRequestPayerPhoneTrueAndValidPayerPhoneInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerPhone(true);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_phone = "0123";
|
| +
|
| + ScriptValue outValue;
|
| + request->show(getScriptState()).then(PaymentResponseFunction::create(getScriptState(), &outValue), MockFunction::expectNoCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| + v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
|
| + PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(getScriptState()->isolate(), outValue.v8Value());
|
| +
|
| + EXPECT_EQ("0123", pr->payerPhone());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, RejectShowPromiseWithRequestPayerPhoneTrueAndEmptyPayerPhoneInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerPhone(true);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_phone = "";
|
| +
|
| + request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptState()), MockFunction::expectCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, RejectShowPromiseWithRequestPayerPhoneTrueAndNullPayerPhoneInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerPhone(true);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_phone = String();
|
| +
|
| + request->show(getScriptState()).then(MockFunction::expectNoCall(getScriptState()), MockFunction::expectCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, ResolveShowPromiseWithRequestPayerPhoneFalseAndEmptyPayerPhoneInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerPhone(false);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| + response->payer_phone = "";
|
| +
|
| + ScriptValue outValue;
|
| + request->show(getScriptState()).then(PaymentResponseFunction::create(getScriptState(), &outValue), MockFunction::expectNoCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| + v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
|
| + PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(getScriptState()->isolate(), outValue.v8Value());
|
| +
|
| + EXPECT_TRUE(pr->payerPhone().isNull());
|
| +}
|
| +
|
| +TEST_F(PaymentRequestTest, ResolveShowPromiseWithRequestPayerPhoneFalseAndNullPayerPhoneInResponse)
|
| +{
|
| + ScriptState::Scope scope(getScriptState());
|
| + PaymentOptions options;
|
| + options.setRequestPayerPhone(false);
|
| + PaymentRequest* request = PaymentRequest::create(getScriptState(), Vector<String>(1, "foo"), buildPaymentDetailsForTest(), options, getExceptionState());
|
| + EXPECT_FALSE(getExceptionState().hadException());
|
| + mojom::blink::PaymentResponsePtr response = mojom::blink::PaymentResponse::New();
|
| +
|
| + ScriptValue outValue;
|
| + request->show(getScriptState()).then(PaymentResponseFunction::create(getScriptState(), &outValue), MockFunction::expectNoCall(getScriptState()));
|
| +
|
| + static_cast<mojom::blink::PaymentRequestClient*>(request)->OnPaymentResponse(std::move(response));
|
| + v8::MicrotasksScope::PerformCheckpoint(getScriptState()->isolate());
|
| + PaymentResponse* pr = V8PaymentResponse::toImplWithTypeCheck(getScriptState()->isolate(), outValue.v8Value());
|
| +
|
| + EXPECT_TRUE(pr->payerPhone().isNull());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace blink
|
|
|