Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/FilterEngine.cpp

Issue 29335462: Issue 3337 - Update adblockplus reference in libadblockplus to revision hg:813682c7161e (Closed)
Patch Set: rebase Created April 19, 2016, 9:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/FilterEngine.cpp
diff --git a/test/FilterEngine.cpp b/test/FilterEngine.cpp
index 6ec07260955fcb07a3100de3d8253adcb046d1ff..fe31e19fad68447e052f9469b7ee2bdcacd7f538 100644
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -280,6 +280,68 @@ TEST_F(FilterEngineTest, MatchesOnWhitelistedDomain)
ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType());
}
+TEST_F(FilterEngineTest, MatchesWithContentTypeMask)
+{
+ filterEngine->GetFilter("adbanner.gif.js$script,image")->AddToList();
+ filterEngine->GetFilter("@@notbanner.gif")->AddToList();
+ filterEngine->GetFilter("blockme")->AddToList();
+ filterEngine->GetFilter("@@||example.doc^$document")->AddToList();
+
+ EXPECT_FALSE(filterEngine->Matches("http://example.org/foobar.gif",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_IMAGE, ""))
+ << "another url should not match";
+
+ EXPECT_FALSE(filterEngine->Matches("http://example.org/adbanner.gif.js",
+ /*mask*/ 0, "")) << "zero mask should not match (filter with some options)";
+
+ EXPECT_FALSE(filterEngine->Matches("http://example.xxx/blockme",
+ /*mask*/ 0, "")) << "zero mask should not match (filter without any option)";
+
+ EXPECT_FALSE(filterEngine->Matches("http://example.org/adbanner.gif.js",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_OBJECT, ""))
+ << "one arbitrary flag in mask should not match";
+
+ EXPECT_TRUE(filterEngine->Matches("http://example.org/adbanner.gif.js",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_IMAGE |
+ AdblockPlus::FilterEngine::CONTENT_TYPE_OBJECT, ""))
+ << "one of flags in mask should match";
+
+ EXPECT_TRUE(filterEngine->Matches("http://example.org/adbanner.gif.js",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_IMAGE |
+ AdblockPlus::FilterEngine::CONTENT_TYPE_SCRIPT, ""))
+ << "both flags in mask should match";
+
+ EXPECT_TRUE(filterEngine->Matches("http://example.org/adbanner.gif.js",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_IMAGE |
+ AdblockPlus::FilterEngine::CONTENT_TYPE_SCRIPT |
+ AdblockPlus::FilterEngine::CONTENT_TYPE_OBJECT, ""))
+ << "both flags with another flag in mask should match";
+
+ EXPECT_TRUE(filterEngine->Matches("http://example.org/adbanner.gif.js",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_SCRIPT |
+ AdblockPlus::FilterEngine::CONTENT_TYPE_OBJECT, ""))
+ << "one of flags in mask should match";
+
+ {
+ AdblockPlus::FilterPtr filter;
+ ASSERT_TRUE(filter = filterEngine->Matches("http://child.any/blockme",
+ AdblockPlus::FilterEngine::CONTENT_TYPE_SCRIPT |
+ AdblockPlus::FilterEngine::CONTENT_TYPE_OBJECT, "http://example.doc"))
+ << "non-zero mask should match on whitelisted document";
+
+ EXPECT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, filter->GetType());
+ }
+
+ {
+ AdblockPlus::FilterPtr filter;
+ ASSERT_TRUE(filter = filterEngine->Matches("http://example.doc/blockme",
+ /*mask*/0, "http://example.doc"))
+ << "zero mask should match when document is whitelisted";
+
+ EXPECT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, filter->GetType());
+ }
+}
+
TEST_F(FilterEngineTest, MatchesNestedFrameRequest)
{
filterEngine->GetFilter("adbanner.gif")->AddToList();
« no previous file with comments | « src/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld