Skip to content

Commit

Permalink
[Web Payment] Fix hasEnrolledInstrument() query quota test.
Browse files Browse the repository at this point in the history
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: Danyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688540}
  • Loading branch information
rsolomakhin authored and Commit Bot committed Aug 20, 2019
1 parent 697764d commit 6d1bc88
Showing 1 changed file with 49 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,68 @@ class HasEnrolledInstrumentQueryQuotaTest : public PlatformBrowserTest {
return chrome_test_utils::GetActiveWebContents(this);
}

protected:
base::test::ScopedFeatureList features_;

private:
net::EmbeddedTestServer https_server_;

DISALLOW_COPY_AND_ASSIGN(HasEnrolledInstrumentQueryQuotaTest);
};

IN_PROC_BROWSER_TEST_F(HasEnrolledInstrumentQueryQuotaTest, QueryQuota) {
// Payment options do not trigger query quota when the
// kStrictHasEnrolledAutofillInstrument feature is disabled.
// Payment options do not trigger query quota when the strict autofill data
// check is disabled. Per-method query quota is also disabled in this test.
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,
content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()"));
EXPECT_EQ(false,
content::EvalJs(GetActiveWebContents(),
"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;
features.InitAndEnableFeature(features::kStrictHasEnrolledAutofillInstrument);
// Payment options trigger query quota for Basic Card when the strict autofill
// 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,
content::EvalJs(GetActiveWebContents(), "hasEnrolledInstrument()"));
EXPECT_EQ("NotAllowedError: Exceeded query quota for hasEnrolledInstrument",
Expand Down

0 comments on commit 6d1bc88

Please sign in to comment.