Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) | 205 TEST_F(FilterEngineTest, MatchesOnWhitelistedDomain) |
206 { | 206 { |
207 filterEngine->GetFilter("adbanner.gif")->AddToList(); | 207 filterEngine->GetFilter("adbanner.gif")->AddToList(); |
208 filterEngine->GetFilter("@@||example.org$document")->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 | 209 |
210 AdblockPlus::FilterPtr match1 = | 210 AdblockPlus::FilterPtr match1 = |
211 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | 211 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", |
212 "http://example.com/"); | 212 "http://example.com/"); |
213 ASSERT_TRUE(match1); | 213 ASSERT_TRUE(match1); |
214 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); | 214 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); |
215 | 215 |
216 AdblockPlus::FilterPtr match2 = | 216 AdblockPlus::FilterPtr match2 = |
217 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | 217 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", |
218 "http://example.org/"); | 218 "http://example.org/"); |
(...skipping 13 matching lines...) Expand all Loading... | |
232 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | 232 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", |
233 documentUrls1); | 233 documentUrls1); |
234 ASSERT_TRUE(match1); | 234 ASSERT_TRUE(match1); |
235 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); | 235 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); |
236 | 236 |
237 std::vector<std::string> documentUrls2; | 237 std::vector<std::string> documentUrls2; |
238 documentUrls2.push_back("http://ads.com/frame/"); | 238 documentUrls2.push_back("http://ads.com/frame/"); |
239 documentUrls2.push_back("http://example.org/"); | 239 documentUrls2.push_back("http://example.org/"); |
240 AdblockPlus::FilterPtr match2 = | 240 AdblockPlus::FilterPtr match2 = |
241 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | 241 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", |
242 documentUrls2); | 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); | 243 ASSERT_TRUE(match2); |
244 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType()); | 244 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType()); |
245 | |
246 std::vector<std::string> documentUrls3; | |
247 documentUrls3.push_back("http://example.org/"); | |
248 documentUrls3.push_back("http://ads.com/frame/"); | |
249 AdblockPlus::FilterPtr match3 = | |
250 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
251 documentUrls3); | |
252 ASSERT_TRUE(match3); | |
253 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match3->GetType()); | |
245 } | 254 } |
246 | 255 |
247 TEST_F(FilterEngineTest, MatchesNestedFrameOnWhitelistedDomain) | 256 TEST_F(FilterEngineTest, MatchesNestedFrameOnWhitelistedDomain) |
248 { | 257 { |
249 filterEngine->GetFilter("adbanner.gif")->AddToList(); | 258 filterEngine->GetFilter("adbanner.gif")->AddToList(); |
250 filterEngine->GetFilter("@@||example.org$document")->AddToList(); | 259 filterEngine->GetFilter("@@||example.org^$document,domain=ads.com")->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 | 260 |
252 std::vector<std::string> documentUrls1; | 261 std::vector<std::string> documentUrls1; |
253 documentUrls1.push_back("http://ads.com/frame/"); | 262 documentUrls1.push_back("http://ads.com/frame/"); |
254 documentUrls1.push_back("http://example.com/"); | 263 documentUrls1.push_back("http://example.com/"); |
255 AdblockPlus::FilterPtr match1 = | 264 AdblockPlus::FilterPtr match1 = |
256 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | 265 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", |
257 documentUrls1); | 266 documentUrls1); |
258 ASSERT_TRUE(match1); | 267 ASSERT_TRUE(match1); |
259 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); | 268 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match1->GetType()); |
260 | 269 |
261 std::vector<std::string> documentUrls2; | 270 std::vector<std::string> documentUrls2; |
262 documentUrls2.push_back("http://ads.com/frame/"); | 271 documentUrls2.push_back("http://ads.com/frame/"); |
263 documentUrls2.push_back("http://example.org/"); | 272 documentUrls2.push_back("http://example.org/"); |
264 AdblockPlus::FilterPtr match2 = | 273 AdblockPlus::FilterPtr match2 = |
265 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | 274 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", |
266 documentUrls2); | 275 documentUrls2); |
267 ASSERT_TRUE(match2); | 276 ASSERT_TRUE(match2); |
268 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match2->GetType()); | 277 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.
| |
278 | |
279 std::vector<std::string> documentUrls3; | |
280 documentUrls3.push_back("http://example.org/"); | |
281 AdblockPlus::FilterPtr match3 = | |
282 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
283 documentUrls3); | |
284 ASSERT_TRUE(match3); | |
285 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match3->GetType()); | |
286 | |
287 std::vector<std::string> documentUrls4; | |
288 documentUrls4.push_back("http://example.org/"); | |
289 documentUrls4.push_back("http://ads.com/frame/"); | |
290 AdblockPlus::FilterPtr match4 = | |
291 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
292 documentUrls4); | |
293 ASSERT_TRUE(match4); | |
294 ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match4->GetType()); | |
295 | |
296 std::vector<std::string> documentUrls5; | |
297 documentUrls5.push_back("http://ads.com/frame/"); | |
298 documentUrls5.push_back("http://example.org/"); | |
299 documentUrls5.push_back("http://example.com/"); | |
300 AdblockPlus::FilterPtr match5 = | |
301 filterEngine->Matches("http://ads.com/adbanner.gif", "IMAGE", | |
302 documentUrls5); | |
303 ASSERT_TRUE(match5); | |
304 ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match5->GetType()); | |
269 } | 305 } |
270 | 306 |
271 TEST_F(FilterEngineTest, FirstRunFlag) | 307 TEST_F(FilterEngineTest, FirstRunFlag) |
272 { | 308 { |
273 ASSERT_FALSE(filterEngine->IsFirstRun()); | 309 ASSERT_FALSE(filterEngine->IsFirstRun()); |
274 } | 310 } |
275 | 311 |
276 TEST_F(FilterEngineTestNoData, FirstRunFlag) | 312 TEST_F(FilterEngineTestNoData, FirstRunFlag) |
277 { | 313 { |
278 ASSERT_FALSE(filterEngine->IsFirstRun()); | 314 ASSERT_FALSE(filterEngine->IsFirstRun()); |
279 } | 315 } |
LEFT | RIGHT |