Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 ASSERT_FALSE(match10); | 195 ASSERT_FALSE(match10); |
196 | 196 |
197 AdblockPlus::FilterPtr match11 = filterEngine->Matches("http://example.org/org banner.gif", "IMAGE", "http://example.com/"); | 197 AdblockPlus::FilterPtr match11 = filterEngine->Matches("http://example.org/org banner.gif", "IMAGE", "http://example.com/"); |
198 ASSERT_FALSE(match11); | 198 ASSERT_FALSE(match11); |
199 | 199 |
200 AdblockPlus::FilterPtr match12 = filterEngine->Matches("http://example.org/org banner.gif", "IMAGE", "http://example.org/"); | 200 AdblockPlus::FilterPtr match12 = filterEngine->Matches("http://example.org/org banner.gif", "IMAGE", "http://example.org/"); |
201 ASSERT_TRUE(match12); | 201 ASSERT_TRUE(match12); |
202 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match12->GetType()); | 202 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match12->GetType()); |
203 } | 203 } |
204 | 204 |
205 TEST_F(FilterEngineTest, MatchesOnWhitelistedDomain) | |
206 { | |
207 filterEngine->GetFilter("adbanner.gif")->AddToList(); | |
208 filterEngine->GetFilter("@@||example.org$document")->AddToList(); | |
Wladimir Palant
2013/11/04 07:17:28
Nit: This should be @@||example.org^$document (^ i
Felix Dahlke
2013/11/15 08:18:19
Done.
| |
209 | |
210 AdblockPlus::FilterPtr match1 = | |
211 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
212 "http://example.com/"); | |
213 ASSERT_TRUE(match1); | |
214 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); | |
215 | |
216 AdblockPlus::FilterPtr match2 = | |
217 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
218 "http://example.org/"); | |
219 ASSERT_TRUE(match2); | |
220 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType()); | |
221 } | |
222 | |
223 TEST_F(FilterEngineTest, MatchesNestedFrameRequest) | |
224 { | |
225 filterEngine->GetFilter("adbanner.gif")->AddToList(); | |
226 filterEngine->GetFilter("@@adbanner.gif$domain=example.org")->AddToList(); | |
227 | |
228 std::vector<std::string> documentUrls1; | |
229 documentUrls1.push_back("http://ads.com/frame/"); | |
230 documentUrls1.push_back("http://example.com/"); | |
231 AdblockPlus::FilterPtr match1 = | |
232 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
233 documentUrls1); | |
234 ASSERT_TRUE(match1); | |
235 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); | |
236 | |
237 std::vector<std::string> documentUrls2; | |
238 documentUrls2.push_back("http://ads.com/frame/"); | |
239 documentUrls2.push_back("http://example.org/"); | |
240 AdblockPlus::FilterPtr match2 = | |
241 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
242 documentUrls2); | |
Wladimir Palant
2013/11/04 07:17:28
How about an additional test where the document UR
Felix Dahlke
2013/11/15 08:18:19
Done.
| |
243 ASSERT_TRUE(match2); | |
244 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType()); | |
245 } | |
246 | |
247 TEST_F(FilterEngineTest, MatchesNestedFrameOnWhitelistedDomain) | |
248 { | |
249 filterEngine->GetFilter("adbanner.gif")->AddToList(); | |
250 filterEngine->GetFilter("@@||example.org$document")->AddToList(); | |
Wladimir Palant
2013/11/04 07:17:28
Nit: As above, this should be @@||example.org^$doc
Felix Dahlke
2013/11/15 08:18:19
Done.
| |
251 | |
252 std::vector<std::string> documentUrls1; | |
253 documentUrls1.push_back("http://ads.com/frame/"); | |
254 documentUrls1.push_back("http://example.com/"); | |
255 AdblockPlus::FilterPtr match1 = | |
256 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
257 documentUrls1); | |
258 ASSERT_TRUE(match1); | |
259 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); | |
260 | |
261 std::vector<std::string> documentUrls2; | |
262 documentUrls2.push_back("http://ads.com/frame/"); | |
263 documentUrls2.push_back("http://example.org/"); | |
264 AdblockPlus::FilterPtr match2 = | |
265 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
266 documentUrls2); | |
267 ASSERT_TRUE(match2); | |
268 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType()); | |
Wladimir Palant
2013/11/04 07:17:28
I would add a few more tests here:
* http://examp
Felix Dahlke
2013/11/15 08:18:19
Done.
| |
269 } | |
270 | |
205 TEST_F(FilterEngineTest, FirstRunFlag) | 271 TEST_F(FilterEngineTest, FirstRunFlag) |
206 { | 272 { |
207 ASSERT_FALSE(filterEngine->IsFirstRun()); | 273 ASSERT_FALSE(filterEngine->IsFirstRun()); |
208 } | 274 } |
209 | 275 |
210 TEST_F(FilterEngineTestNoData, FirstRunFlag) | 276 TEST_F(FilterEngineTestNoData, FirstRunFlag) |
211 { | 277 { |
212 ASSERT_FALSE(filterEngine->IsFirstRun()); | 278 ASSERT_FALSE(filterEngine->IsFirstRun()); |
213 } | 279 } |
OLD | NEW |