Commit 6d1bc888 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Web Payment] Fix hasEnrolledInstrument() query quota test.

Before this patch, HasEnrolledInstrumentQueryQuotaTest.QueryQuota would
fail or succeed depending on whether per-method quota flag was enabled
in the test environment.

This patch breaks up the QueryQuota test into several tests, each one
explicitly setting the "strict autofill data check" and "per method
quota" flags at the start to best replicate all possible execution
environments.

After this patch, HasEnrolledInstrumentQueryQuotaTest passes in all test
environments.

Bug: 995728
Change-Id: I1c6812b5ae8b464c7f121bc0ce2ca0fcc5258503
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760881
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Danyao Wang <danyao@chromium.org>
Auto-Submit: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688540}
parent 697764da
...@@ -57,26 +57,68 @@ class HasEnrolledInstrumentQueryQuotaTest : public PlatformBrowserTest { ...@@ -57,26 +57,68 @@ class HasEnrolledInstrumentQueryQuotaTest : public PlatformBrowserTest {
return chrome_test_utils::GetActiveWebContents(this); return chrome_test_utils::GetActiveWebContents(this);
} }
protected:
base::test::ScopedFeatureList features_;
private: private:
net::EmbeddedTestServer https_server_; net::EmbeddedTestServer https_server_;
DISALLOW_COPY_AND_ASSIGN(HasEnrolledInstrumentQueryQuotaTest); DISALLOW_COPY_AND_ASSIGN(HasEnrolledInstrumentQueryQuotaTest);
}; };
IN_PROC_BROWSER_TEST_F(HasEnrolledInstrumentQueryQuotaTest, QueryQuota) { // Payment options do not trigger query quota when the strict autofill data
// Payment options do not trigger query quota when the // check is disabled. Per-method query quota is also disabled in this test.
// kStrictHasEnrolledAutofillInstrument feature is disabled. IN_PROC_BROWSER_TEST_F(HasEnrolledInstrumentQueryQuotaTest, NoFlags) {
features_.InitWithFeatures(
/*enabled_features=*/{}, /*disabled_features=*/{
features::kStrictHasEnrolledAutofillInstrument,
features::kWebPaymentsPerMethodCanMakePaymentQuota});
EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()"));
EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(),
"hasEnrolledInstrument({requestShipping:true})"));
}
// Payment options do not trigger query quota when the strict autofill data
// check is disabled. Per-method query quota is enabled in this test.
IN_PROC_BROWSER_TEST_F(HasEnrolledInstrumentQueryQuotaTest, PerMethodQuota) {
features_.InitWithFeatures(
/*enabled_features=*/{features::kWebPaymentsPerMethodCanMakePaymentQuota},
/*disabled_features=*/{features::kStrictHasEnrolledAutofillInstrument});
EXPECT_EQ(false, EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()")); content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()"));
EXPECT_EQ(false, EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(), content::EvalJs(GetActiveWebContents(),
"hasEnrolledInstrument({requestShipping:true})")); "hasEnrolledInstrument({requestShipping:true})"));
}
// Payment options trigger query quota for Basic Card when the strict autofill
// data check is enabled. Per-method query quota is disabled in this test.
IN_PROC_BROWSER_TEST_F(HasEnrolledInstrumentQueryQuotaTest,
StrictAutofillDataCheck) {
features_.InitWithFeatures(
/*enabled_features=*/{features::kStrictHasEnrolledAutofillInstrument},
/*disabled_features=*/{
features::kWebPaymentsPerMethodCanMakePaymentQuota});
EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()"));
EXPECT_EQ("NotAllowedError: Exceeded query quota for hasEnrolledInstrument",
content::EvalJs(GetActiveWebContents(),
"hasEnrolledInstrument({requestShipping:true})"));
}
base::test::ScopedFeatureList features; // Payment options trigger query quota for Basic Card when the strict autofill
features.InitAndEnableFeature(features::kStrictHasEnrolledAutofillInstrument); // data check is enabled. Per-method query quota is also enabled in this test.
IN_PROC_BROWSER_TEST_F(HasEnrolledInstrumentQueryQuotaTest, BothFlags) {
features_.InitWithFeatures(
/*enabled_features=*/{features::kStrictHasEnrolledAutofillInstrument,
features::kWebPaymentsPerMethodCanMakePaymentQuota},
/*disabled_features=*/{});
// Payment options trigger query quota for Basic Card when the
// kStrictHasEnrolledAutofillInstrument feature is enabled.
EXPECT_EQ(false, EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()")); content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()"));
EXPECT_EQ("NotAllowedError: Exceeded query quota for hasEnrolledInstrument", EXPECT_EQ("NotAllowedError: Exceeded query quota for hasEnrolledInstrument",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment