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

Unified Diff: third_party/WebKit/Source/modules/payments/OnPaymentResponseTest.cpp

Issue 2697123003: Use ExecutionContext instead of Document in PaymentRequest constructor. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/OnPaymentResponseTest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/OnPaymentResponseTest.cpp b/third_party/WebKit/Source/modules/payments/OnPaymentResponseTest.cpp
index 64b02305f4305df5e4f865af8598cd329883f0fe..b69d0009bb736fab982b99d4d3adfa94a7098780 100644
--- a/third_party/WebKit/Source/modules/payments/OnPaymentResponseTest.cpp
+++ b/third_party/WebKit/Source/modules/payments/OnPaymentResponseTest.cpp
@@ -25,7 +25,7 @@ TEST(OnPaymentResponseTest, RejectMissingShippingOption) {
PaymentOptions options;
options.setRequestShipping(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -35,8 +35,7 @@ TEST(OnPaymentResponseTest, RejectMissingShippingOption) {
response->shipping_address->language_code = "en";
response->shipping_address->script_code = "Latn";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -51,15 +50,14 @@ TEST(OnPaymentResponseTest, RejectMissingAddress) {
PaymentOptions options;
options.setRequestShipping(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
buildPaymentResponseForTest();
response->shipping_option = "standardShipping";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -74,14 +72,13 @@ TEST(OnPaymentResponseTest, RejectMissingName) {
PaymentOptions options;
options.setRequestPayerName(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -96,14 +93,13 @@ TEST(OnPaymentResponseTest, RejectMissingEmail) {
PaymentOptions options;
options.setRequestPayerEmail(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -118,14 +114,13 @@ TEST(OnPaymentResponseTest, RejectMissingPhone) {
PaymentOptions options;
options.setRequestPayerPhone(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -140,7 +135,7 @@ TEST(OnPaymentResponseTest, RejectEmptyShippingOption) {
PaymentOptions options;
options.setRequestShipping(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -151,8 +146,7 @@ TEST(OnPaymentResponseTest, RejectEmptyShippingOption) {
response->shipping_address->language_code = "en";
response->shipping_address->script_code = "Latn";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -167,7 +161,7 @@ TEST(OnPaymentResponseTest, RejectEmptyAddress) {
PaymentOptions options;
options.setRequestShipping(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -175,8 +169,7 @@ TEST(OnPaymentResponseTest, RejectEmptyAddress) {
response->shipping_option = "standardShipping";
response->shipping_address = payments::mojom::blink::PaymentAddress::New();
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -191,15 +184,14 @@ TEST(OnPaymentResponseTest, RejectEmptyName) {
PaymentOptions options;
options.setRequestPayerName(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_name = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -214,15 +206,14 @@ TEST(OnPaymentResponseTest, RejectEmptyEmail) {
PaymentOptions options;
options.setRequestPayerEmail(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_email = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -237,15 +228,14 @@ TEST(OnPaymentResponseTest, RejectEmptyPhone) {
PaymentOptions options;
options.setRequestPayerPhone(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_phone = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -260,7 +250,7 @@ TEST(OnPaymentResponseTest, RejectNotRequestedAddress) {
PaymentOptions options;
options.setRequestShipping(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -270,8 +260,7 @@ TEST(OnPaymentResponseTest, RejectNotRequestedAddress) {
response->shipping_address->language_code = "en";
response->shipping_address->script_code = "Latn";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -286,15 +275,14 @@ TEST(OnPaymentResponseTest, RejectNotRequestedShippingOption) {
PaymentOptions options;
options.setRequestShipping(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->shipping_option = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -309,15 +297,14 @@ TEST(OnPaymentResponseTest, RejectNotRequestedName) {
PaymentOptions options;
options.setRequestPayerName(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_name = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -332,15 +319,14 @@ TEST(OnPaymentResponseTest, RejectNotRequestedEmail) {
PaymentOptions options;
options.setRequestPayerEmail(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_email = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -355,15 +341,14 @@ TEST(OnPaymentResponseTest, RejectNotRequestedPhone) {
PaymentOptions options;
options.setRequestPayerPhone(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_phone = "";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -378,7 +363,7 @@ TEST(OnPaymentResponseTest, RejectInvalidAddress) {
PaymentOptions options;
options.setRequestShipping(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -387,8 +372,7 @@ TEST(OnPaymentResponseTest, RejectInvalidAddress) {
response->shipping_address = payments::mojom::blink::PaymentAddress::New();
response->shipping_address->country = "Atlantis";
- request->show(scope.getScriptState())
- .then(funcs.expectNoCall(), funcs.expectCall());
+ request->show().then(funcs.expectNoCall(), funcs.expectCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -427,7 +411,7 @@ TEST(OnPaymentResponseTest, CanRequestShippingInformation) {
PaymentOptions options;
options.setRequestShipping(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -438,9 +422,9 @@ TEST(OnPaymentResponseTest, CanRequestShippingInformation) {
response->shipping_address->language_code = "en";
response->shipping_address->script_code = "Latn";
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -462,16 +446,16 @@ TEST(OnPaymentResponseTest, CanRequestName) {
PaymentOptions options;
options.setRequestPayerName(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_name = "Jon Doe";
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -491,16 +475,16 @@ TEST(OnPaymentResponseTest, CanRequestEmail) {
PaymentOptions options;
options.setRequestPayerEmail(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_email = "abc@gmail.com";
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -520,7 +504,7 @@ TEST(OnPaymentResponseTest, CanRequestPhone) {
PaymentOptions options;
options.setRequestPayerPhone(true);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
@@ -528,9 +512,9 @@ TEST(OnPaymentResponseTest, CanRequestPhone) {
response->payer_phone = "0123";
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -550,13 +534,13 @@ TEST(OnPaymentResponseTest, ShippingInformationNotRequired) {
PaymentOptions options;
options.setRequestShipping(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
ASSERT_FALSE(scope.getExceptionState().hadException());
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(buildPaymentResponseForTest());
@@ -577,16 +561,16 @@ TEST(OnPaymentResponseTest, PhoneNotRequred) {
PaymentOptions options;
options.setRequestPayerPhone(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_phone = String();
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -606,16 +590,16 @@ TEST(OnPaymentResponseTest, NameNotRequired) {
PaymentOptions options;
options.setRequestPayerName(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_name = String();
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));
@@ -635,16 +619,16 @@ TEST(OnPaymentResponseTest, EmailNotRequired) {
PaymentOptions options;
options.setRequestPayerEmail(false);
PaymentRequest* request = PaymentRequest::create(
- scope.document(), buildPaymentMethodDataForTest(),
+ scope.getScriptState(), buildPaymentMethodDataForTest(),
buildPaymentDetailsForTest(), options, scope.getExceptionState());
EXPECT_FALSE(scope.getExceptionState().hadException());
payments::mojom::blink::PaymentResponsePtr response =
payments::mojom::blink::PaymentResponse::New();
response->payer_email = String();
ScriptValue outValue;
- request->show(scope.getScriptState())
- .then(PaymentResponseFunction::create(scope.getScriptState(), &outValue),
- funcs.expectNoCall());
+ request->show().then(
+ PaymentResponseFunction::create(scope.getScriptState(), &outValue),
+ funcs.expectNoCall());
static_cast<payments::mojom::blink::PaymentRequestClient*>(request)
->OnPaymentResponse(std::move(response));

Powered by Google App Engine
This is Rietveld 408576698