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

Side by Side Diff: chrome/browser/browsing_data/registrable_domain_filter_builder_unittest.cc

Issue 2248403002: Implement origin-based deletion of plugin data (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/browsing_data/registrable_domain_filter_builder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" 5 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 490
491 // Channel IDs that are not blacklisted are matched. 491 // Channel IDs that are not blacklisted are matched.
492 {"example.com", true}, 492 {"example.com", true},
493 {"192.168.1.2", true}, 493 {"192.168.1.2", true},
494 {"website.fileserver", true}, 494 {"website.fileserver", true},
495 }; 495 };
496 496
497 for (TestCase test_case : test_cases) 497 for (TestCase test_case : test_cases)
498 RunTestCase(test_case, filter); 498 RunTestCase(test_case, filter);
499 } 499 }
500
501 TEST(RegistrableDomainFilterBuilderTest, MatchesPluginSitesWhitelist) {
502 RegistrableDomainFilterBuilder builder(
503 RegistrableDomainFilterBuilder::WHITELIST);
504 builder.AddRegisterableDomain(std::string(kGoogleDomain));
505 builder.AddRegisterableDomain(std::string(kLongETLDDomain));
506 builder.AddRegisterableDomain(std::string(kIPAddress));
507 builder.AddRegisterableDomain(std::string(kUnknownRegistryDomain));
508 builder.AddRegisterableDomain(std::string(kInternalHostname));
509 base::Callback<bool(const std::string&)> filter =
510 builder.BuildPluginFilter();
511
512 TestCase test_cases[] = {
513 // Plugin sites can be domains, ...
514 {"google.com", true},
515 {"www.google.com", true},
516 {"website.sp.nom.br", true},
517 {"www.website.sp.nom.br", true},
518 {"second-level-domain.fileserver", true},
519 {"foo.bar.second-level-domain.fileserver", true},
520
521 // ... IP addresses, or internal hostnames.
522 {"192.168.1.1", true},
523 {"fileserver", true},
524
525 // Sites not in the whitelist are not matched.
526 {"example.com", false},
527 {"192.168.1.2", false},
528 {"website.fileserver", false},
529 };
530
531 for (TestCase test_case : test_cases)
532 RunTestCase(test_case, filter);
533 }
534
535 TEST(RegistrableDomainFilterBuilderTest, MatchesPluginSitesBlacklist) {
536 RegistrableDomainFilterBuilder builder(
537 RegistrableDomainFilterBuilder::BLACKLIST);
538 builder.AddRegisterableDomain(std::string(kGoogleDomain));
539 builder.AddRegisterableDomain(std::string(kLongETLDDomain));
540 builder.AddRegisterableDomain(std::string(kIPAddress));
541 builder.AddRegisterableDomain(std::string(kUnknownRegistryDomain));
542 builder.AddRegisterableDomain(std::string(kInternalHostname));
543 base::Callback<bool(const std::string&)> filter =
544 builder.BuildPluginFilter();
545
546 TestCase test_cases[] = {
547 // Plugin sites can be domains, ...
548 {"google.com", false},
549 {"www.google.com", false},
550 {"website.sp.nom.br", false},
551 {"www.website.sp.nom.br", false},
552 {"second-level-domain.fileserver", false},
553 {"foo.bar.second-level-domain.fileserver", false},
554
555 // ... IP addresses, or internal hostnames.
556 {"192.168.1.1", false},
557 {"fileserver", false},
558
559 // Sites not in the blacklist are matched.
560 {"example.com", true},
561 {"192.168.1.2", true},
562 {"website.fileserver", true},
563 };
564
565 for (TestCase test_case : test_cases)
566 RunTestCase(test_case, filter);
567 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/registrable_domain_filter_builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698