| Index: components/subresource_filter/content/renderer/subresource_filter_agent_unittest.cc
|
| diff --git a/components/subresource_filter/content/renderer/subresource_filter_agent_unittest.cc b/components/subresource_filter/content/renderer/subresource_filter_agent_unittest.cc
|
| index 032936387626431be6b11f288529ca7c0a3782ea..af0b96c017502541bc555940f8680a00319c1d8a 100644
|
| --- a/components/subresource_filter/content/renderer/subresource_filter_agent_unittest.cc
|
| +++ b/components/subresource_filter/content/renderer/subresource_filter_agent_unittest.cc
|
| @@ -20,6 +20,7 @@
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "third_party/WebKit/public/platform/WebDocumentSubresourceFilter.h"
|
| +#include "third_party/WebKit/public/platform/WebDocumentSubresourceFilterLoadPolicy.h"
|
| #include "third_party/WebKit/public/platform/WebURL.h"
|
| #include "third_party/WebKit/public/platform/WebURLRequest.h"
|
| #include "url/gurl.h"
|
| @@ -172,18 +173,19 @@ class SubresourceFilterAgentTest : public ::testing::Test {
|
|
|
| void ExpectLoadPolicy(
|
| base::StringPiece url_spec,
|
| - blink::WebDocumentSubresourceFilter::LoadPolicy expected_policy) {
|
| + blink::WebDocumentSubresourceFilterLoadPolicy expected_policy) {
|
| blink::WebURL url = GURL(url_spec);
|
| blink::WebURLRequest::RequestContext request_context =
|
| blink::WebURLRequest::RequestContextImage;
|
| - blink::WebDocumentSubresourceFilter::LoadPolicy actual_policy =
|
| + blink::WebDocumentSubresourceFilterLoadPolicy actual_policy =
|
| agent()->filter()->getLoadPolicy(url, request_context);
|
| EXPECT_EQ(expected_policy, actual_policy);
|
|
|
| // If the load policy indicated the load was filtered, simulate a filtered
|
| // load callback. In production, this will be called in FrameFetchContext,
|
| // but we simulate the call here.
|
| - if (actual_policy == blink::WebDocumentSubresourceFilter::Disallow)
|
| + if (actual_policy ==
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow)
|
| agent()->filter()->reportDisallowedLoad();
|
| }
|
|
|
| @@ -284,8 +286,9 @@ TEST_F(SubresourceFilterAgentTest, Enabled_FilteringIsInEffectForOneLoad) {
|
|
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| - ExpectLoadPolicy(kTestSecondURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| + ExpectLoadPolicy(kTestSecondURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
|
|
| @@ -294,8 +297,9 @@ TEST_F(SubresourceFilterAgentTest, Enabled_FilteringIsInEffectForOneLoad) {
|
| ExpectNoSignalAboutFirstSubresourceDisallowed();
|
| PerformSamePageNavigationWithoutSettingActivationLevel();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| - ExpectLoadPolicy(kTestSecondURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| + ExpectLoadPolicy(kTestSecondURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
|
|
| ExpectNoSubresourceFilterGetsInjected();
|
| StartLoadWithoutSettingActivationLevel();
|
| @@ -326,13 +330,13 @@ TEST_F(SubresourceFilterAgentTest, Enabled_HistogramSamplesOverTwoLoads) {
|
|
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| ExpectNoSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| ExpectNoSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestSecondURL,
|
| - blink::WebDocumentSubresourceFilter::Allow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
|
|
| @@ -343,10 +347,10 @@ TEST_F(SubresourceFilterAgentTest, Enabled_HistogramSamplesOverTwoLoads) {
|
|
|
| ExpectNoSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestSecondURL,
|
| - blink::WebDocumentSubresourceFilter::Allow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
|
|
| @@ -387,8 +391,9 @@ TEST_F(SubresourceFilterAgentTest, Enabled_NewRulesetIsPickedUpAtNextLoad) {
|
|
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| - ExpectLoadPolicy(kTestSecondURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| + ExpectLoadPolicy(kTestSecondURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
|
|
| @@ -397,9 +402,10 @@ TEST_F(SubresourceFilterAgentTest, Enabled_NewRulesetIsPickedUpAtNextLoad) {
|
| ASSERT_TRUE(::testing::Mock::VerifyAndClearExpectations(agent()));
|
|
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| - ExpectLoadPolicy(kTestFirstURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + ExpectLoadPolicy(kTestFirstURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectLoadPolicy(kTestSecondURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
| }
|
| @@ -434,11 +440,14 @@ TEST_F(SubresourceFilterAgentTest, DryRun_ResourcesAreEvaluatedButNotFiltered) {
|
| // In dry-run mode, loads to the first URL should be recorded as
|
| // `MatchedRules`, but still be allowed to proceed and not recorded as
|
| // `Disallowed`.
|
| - ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::WouldDisallow);
|
| - ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::WouldDisallow);
|
| - ExpectLoadPolicy(kTestSecondURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + ExpectLoadPolicy(
|
| + kTestFirstURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::WouldDisallow);
|
| + ExpectLoadPolicy(
|
| + kTestFirstURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::WouldDisallow);
|
| + ExpectLoadPolicy(kTestSecondURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
|
|
| @@ -467,11 +476,12 @@ TEST_F(SubresourceFilterAgentTest,
|
|
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| ExpectNoSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| - ExpectLoadPolicy(kTestSecondURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| + ExpectLoadPolicy(kTestSecondURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
|
|
| @@ -479,10 +489,11 @@ TEST_F(SubresourceFilterAgentTest,
|
| StartLoadAndSetActivationLevel(ActivationLevel::ENABLED);
|
| ASSERT_TRUE(::testing::Mock::VerifyAndClearExpectations(agent()));
|
|
|
| - ExpectLoadPolicy(kTestSecondURL, blink::WebDocumentSubresourceFilter::Allow);
|
| + ExpectLoadPolicy(kTestSecondURL,
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Allow);
|
| ExpectSignalAboutFirstSubresourceDisallowed();
|
| ExpectLoadPolicy(kTestFirstURL,
|
| - blink::WebDocumentSubresourceFilter::Disallow);
|
| + blink::WebDocumentSubresourceFilterLoadPolicy::Disallow);
|
| ExpectDocumentLoadStatisticsSent();
|
| FinishLoad();
|
| }
|
|
|