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

Unified Diff: chrome/browser/browsing_data/origin_filter_builder_unittest.cc

Issue 1741123002: Add removal filter support for Cookies, Storage, and Content Settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed class, comments Created 4 years, 8 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: chrome/browser/browsing_data/origin_filter_builder_unittest.cc
diff --git a/chrome/browser/browsing_data/origin_filter_builder_unittest.cc b/chrome/browser/browsing_data/origin_filter_builder_unittest.cc
deleted file mode 100644
index 32fef25dadf3028c49a8e48852343732e3b5e3fd..0000000000000000000000000000000000000000
--- a/chrome/browser/browsing_data/origin_filter_builder_unittest.cc
+++ /dev/null
@@ -1,140 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/browsing_data/origin_filter_builder.h"
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-#include "base/callback.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "url/gurl.h"
-#include "url/origin.h"
-
-namespace url {
-
-namespace {
-
-struct TestCase {
- std::string url;
- bool should_match;
-};
-
-void RunTestCase(
- TestCase test_case, const base::Callback<bool(const GURL&)>& filter) {
- if (test_case.should_match)
- EXPECT_TRUE(filter.Run(GURL(test_case.url)));
- else
- EXPECT_FALSE(filter.Run(GURL(test_case.url)));
-}
-
-} // namespace
-
-TEST(OriginFilterBuilderTest, Noop) {
- // An no-op filter matches everything.
- base::Callback<bool(const GURL&)> filter =
- OriginFilterBuilder::BuildNoopFilter();
-
- TestCase test_cases[] = {
- { "https://www.google.com", true },
- { "https://www.chrome.com", true },
- { "invalid url spec", true }
- };
-
- for (TestCase test_case : test_cases)
- RunTestCase(test_case, filter);
-}
-
-TEST(OriginFilterBuilderTest, Whitelist) {
- OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST);
- builder.AddOrigin(Origin(GURL("https://www.google.com")));
- builder.AddOrigin(Origin(GURL("http://www.example.com")));
- base::Callback<bool(const GURL&)> filter = builder.BuildSameOriginFilter();
-
- TestCase test_cases[] = {
- // Whitelist matches any URL on the specified origins.
- { "https://www.google.com", true },
- { "https://www.google.com/?q=test", true },
- { "http://www.example.com", true },
- { "http://www.example.com/index.html", true },
- { "http://www.example.com/foo/bar", true },
-
- // Subdomains are different origins.
- { "https://test.www.google.com", false },
-
- // Different scheme or port is a different origin.
- { "https://www.google.com:8000", false },
- { "https://www.example.com/index.html", false },
-
- // Different host is a different origin.
- { "https://www.youtube.com", false },
- { "https://www.chromium.org", false },
- };
-
- for (TestCase test_case : test_cases)
- RunTestCase(test_case, filter);
-}
-
-TEST(OriginFilterBuilderTest, Blacklist) {
- OriginFilterBuilder builder(OriginFilterBuilder::BLACKLIST);
- builder.AddOrigin(Origin(GURL("https://www.google.com")));
- builder.AddOrigin(Origin(GURL("http://www.example.com")));
- base::Callback<bool(const GURL&)> filter = builder.BuildSameOriginFilter();
-
- TestCase test_cases[] = {
- // URLS on explicitly specified origins are not matched.
- { "https://www.google.com", false },
- { "https://www.google.com/?q=test", false },
- { "http://www.example.com", false },
- { "http://www.example.com/index.html", false },
- { "http://www.example.com/foo/bar", false },
-
- // Subdomains are different origins.
- { "https://test.www.google.com", true },
-
- // The same hosts but with different schemes and ports
- // are not blacklisted.
- { "https://www.google.com:8000", true },
- { "https://www.example.com/index.html", true },
-
- // Different hosts are not blacklisted.
- { "https://www.chrome.com", true },
- { "https://www.youtube.com", true },
- };
-
- for (TestCase test_case : test_cases)
- RunTestCase(test_case, filter);
-}
-
-TEST(OriginFilterBuilderTest, MatchesURLWithSubdomain) {
- OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST);
- builder.AddOrigin(Origin(GURL("https://www.google.com")));
- base::Callback<bool(const GURL&)> filter = builder.BuildDomainFilter();
-
- TestCase test_cases[] = {
- // Any URL on the specified origin is matched.
- { "https://www.google.com", true },
- { "https://www.google.com/test.html", true },
-
- // Subdomains are also matched.
- { "https://foo.www.google.com", true },
- { "https://foo.www.google.com/?q=test", true },
- { "https://foo.bar.www.google.com", true },
- { "https://foo.bar.www.google.com/test.html", true },
- { "https://foo.bar.baz.www.google.com", true },
-
- // Superdomains are not matched.
- { "https://google.com", false },
-
- // Different hosts are not matched.
- { "https://www.chrome.com", false },
- { "https://www.youtube.com", false },
- };
-
- for (TestCase test_case : test_cases)
- RunTestCase(test_case, filter);
-}
-
-} // namespace url

Powered by Google App Engine
This is Rietveld 408576698