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

Side by Side Diff: test/filterStorage.js

Issue 30009567: Issue 7295 - Add non-active filters to blocking group (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 16, 2019, 2:17 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/subscriptionClasses.js ('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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 filterStorage.addFilter(Filter.fromText("foo##bar")); 251 filterStorage.addFilter(Filter.fromText("foo##bar"));
252 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo##bar"] , []]); 252 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo##bar"] , []]);
253 test.deepEqual(changes, ["filter.added foo##bar"], "Received changes"); 253 test.deepEqual(changes, ["filter.added foo##bar"], "Received changes");
254 254
255 changes = []; 255 changes = [];
256 filterStorage.addFilter(Filter.fromText("foo#@#bar")); 256 filterStorage.addFilter(Filter.fromText("foo#@#bar"));
257 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo## bar", "foo#@#bar"], []]); 257 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo## bar", "foo#@#bar"], []]);
258 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes"); 258 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes");
259 259
260 changes = []; 260 changes = [];
261 filterStorage.addFilter(Filter.fromText("example.com#$#foobar"));
Manish Jethani 2019/02/16 14:19:23 We still need to test for the case where a filter
262 compareFiltersList(test, "Adding snippet filter", [["foo"], ["@@bar", "foo##ba r", "foo#@#bar"], ["example.com#$#foobar"]]);
263 test.deepEqual(changes, ["filter.added example.com#$#foobar"], "Received chang es");
264
265 changes = [];
261 filterStorage.addFilter(Filter.fromText("!foobar")); 266 filterStorage.addFilter(Filter.fromText("!foobar"));
262 compareFiltersList(test, "Adding comment", [["foo"], ["@@bar", "foo##bar", "fo o#@#bar"], ["!foobar"]]); 267 compareFiltersList(test, "Adding comment", [["foo", "!foobar"], ["@@bar", "foo ##bar", "foo#@#bar"], ["example.com#$#foobar"]]);
263 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); 268 test.deepEqual(changes, ["filter.added !foobar"], "Received changes");
264 269
265 changes = []; 270 changes = [];
266 filterStorage.addFilter(Filter.fromText("foo")); 271 filterStorage.addFilter(Filter.fromText("foo"));
267 compareFiltersList(test, "Adding already added filter", [["foo"], ["@@bar", "f oo##bar", "foo#@#bar"], ["!foobar"]]); 272 compareFiltersList(test, "Adding already added filter", [["foo", "!foobar"], [ "@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar"]]);
268 test.deepEqual(changes, [], "Received changes"); 273 test.deepEqual(changes, [], "Received changes");
269 274
270 subscription1.disabled = true; 275 subscription1.disabled = true;
271 276
272 changes = []; 277 changes = [];
273 filterStorage.addFilter(Filter.fromText("foo")); 278 filterStorage.addFilter(Filter.fromText("foo"));
274 compareFiltersList(test, "Adding filter already in a disabled subscription", [ ["foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["!foobar", "foo"]]); 279 compareFiltersList(test, "Adding filter already in a disabled subscription", [ ["foo", "!foobar"], ["@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar", "foo"]]);
275 test.deepEqual(changes, ["filter.added foo"], "Received changes"); 280 test.deepEqual(changes, ["filter.added foo"], "Received changes");
276 281
277 changes = []; 282 changes = [];
278 filterStorage.addFilter(Filter.fromText("foo"), subscription1); 283 filterStorage.addFilter(Filter.fromText("foo"), subscription1);
279 compareFiltersList(test, "Adding filter to an explicit subscription", [["foo", "foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["!foobar", "foo"]]); 284 compareFiltersList(test, "Adding filter to an explicit subscription", [["foo", "!foobar", "foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar", "foo"]]);
280 test.deepEqual(changes, ["filter.added foo"], "Received changes"); 285 test.deepEqual(changes, ["filter.added foo"], "Received changes");
281 286
282 changes = []; 287 changes = [];
283 filterStorage.addFilter(Filter.fromText("!foobar"), subscription2, 0); 288 filterStorage.addFilter(Filter.fromText("example.com#$#foobar"), subscription2 , 0);
284 compareFiltersList(test, "Adding filter to an explicit subscription with posit ion", [["foo", "foo"], ["!foobar", "@@bar", "foo##bar", "foo#@#bar"], ["!foobar" , "foo"]]); 289 compareFiltersList(test, "Adding filter to an explicit subscription with posit ion", [["foo", "!foobar", "foo"], ["example.com#$#foobar", "@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar", "foo"]]);
285 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); 290 test.deepEqual(changes, ["filter.added example.com#$#foobar"], "Received chang es");
286 291
287 test.done(); 292 test.done();
288 }; 293 };
289 294
290 exports.testRemovingFilters = function(test) 295 exports.testRemovingFilters = function(test)
291 { 296 {
292 let subscription1 = Subscription.fromURL("~foo"); 297 let subscription1 = Subscription.fromURL("~foo");
293 subscription1.addFilter(Filter.fromText("foo")); 298 subscription1.addFilter(Filter.fromText("foo"));
294 subscription1.addFilter(Filter.fromText("foo")); 299 subscription1.addFilter(Filter.fromText("foo"));
295 subscription1.addFilter(Filter.fromText("bar")); 300 subscription1.addFilter(Filter.fromText("bar"));
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 compareFilterSubscriptions(test, "filter3 subscriptions after updating http:// test3/ filters", filter3, [subscription2]); 517 compareFilterSubscriptions(test, "filter3 subscriptions after updating http:// test3/ filters", filter3, [subscription2]);
513 518
514 filterStorage.removeSubscription(subscription3); 519 filterStorage.removeSubscription(subscription3);
515 520
516 compareFilterSubscriptions(test, "filter1 subscriptions after removing http:// test3/", filter1, []); 521 compareFilterSubscriptions(test, "filter1 subscriptions after removing http:// test3/", filter1, []);
517 compareFilterSubscriptions(test, "filter2 subscriptions after removing http:// test3/", filter2, [subscription2]); 522 compareFilterSubscriptions(test, "filter2 subscriptions after removing http:// test3/", filter2, [subscription2]);
518 compareFilterSubscriptions(test, "filter3 subscriptions after removing http:// test3/", filter3, [subscription2]); 523 compareFilterSubscriptions(test, "filter3 subscriptions after removing http:// test3/", filter3, [subscription2]);
519 524
520 test.done(); 525 test.done();
521 }; 526 };
OLDNEW
« no previous file with comments | « lib/subscriptionClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld