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

Side by Side Diff: test/filterStorage.js

Issue 29854576: Issue 6859 - Create special subscription group for snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Aug. 12, 2018, 11:20 a.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 | « test/data/patterns.ini ('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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 test.done(); 204 test.done();
205 }; 205 };
206 206
207 exports.testAddingFilters = function(test) 207 exports.testAddingFilters = function(test)
208 { 208 {
209 let subscription1 = Subscription.fromURL("~blocking"); 209 let subscription1 = Subscription.fromURL("~blocking");
210 subscription1.defaults = ["blocking"]; 210 subscription1.defaults = ["blocking"];
211 211
212 let subscription2 = Subscription.fromURL("~exceptions"); 212 let subscription2 = Subscription.fromURL("~exceptions");
213 subscription2.defaults = ["whitelist", "elemhide"]; 213 subscription2.defaults = ["whitelist", "elemhide", "snippet"];
214 214
215 let subscription3 = Subscription.fromURL("~other"); 215 let subscription3 = Subscription.fromURL("~other");
216 216
217 FilterStorage.addSubscription(subscription1); 217 FilterStorage.addSubscription(subscription1);
218 FilterStorage.addSubscription(subscription2); 218 FilterStorage.addSubscription(subscription2);
219 FilterStorage.addSubscription(subscription3); 219 FilterStorage.addSubscription(subscription3);
220 220
221 let changes = []; 221 let changes = [];
222 function listener(action, filter) 222 function listener(action, filter)
223 { 223 {
(...skipping 19 matching lines...) Expand all
243 FilterStorage.addFilter(Filter.fromText("foo##bar")); 243 FilterStorage.addFilter(Filter.fromText("foo##bar"));
244 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo##bar"] , []]); 244 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo##bar"] , []]);
245 test.deepEqual(changes, ["filter.added foo##bar"], "Received changes"); 245 test.deepEqual(changes, ["filter.added foo##bar"], "Received changes");
246 246
247 changes = []; 247 changes = [];
248 FilterStorage.addFilter(Filter.fromText("foo#@#bar")); 248 FilterStorage.addFilter(Filter.fromText("foo#@#bar"));
249 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo## bar", "foo#@#bar"], []]); 249 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo## bar", "foo#@#bar"], []]);
250 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes"); 250 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes");
251 251
252 changes = []; 252 changes = [];
253 FilterStorage.addFilter(Filter.fromText("example.com#$#foo"));
254 compareFiltersList(test, "Adding snippet script", [["foo"], ["@@bar", "foo##ba r", "foo#@#bar", "example.com#$#foo"], []]);
255 test.deepEqual(changes, ["filter.added example.com#$#foo"], "Received changes" );
256
257 changes = [];
253 FilterStorage.addFilter(Filter.fromText("!foobar")); 258 FilterStorage.addFilter(Filter.fromText("!foobar"));
254 compareFiltersList(test, "Adding comment", [["foo"], ["@@bar", "foo##bar", "fo o#@#bar"], ["!foobar"]]); 259 compareFiltersList(test, "Adding comment", [["foo"], ["@@bar", "foo##bar", "fo o#@#bar", "example.com#$#foo"], ["!foobar"]]);
255 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); 260 test.deepEqual(changes, ["filter.added !foobar"], "Received changes");
256 261
257 changes = []; 262 changes = [];
258 FilterStorage.addFilter(Filter.fromText("foo")); 263 FilterStorage.addFilter(Filter.fromText("foo"));
259 compareFiltersList(test, "Adding already added filter", [["foo"], ["@@bar", "f oo##bar", "foo#@#bar"], ["!foobar"]]); 264 compareFiltersList(test, "Adding already added filter", [["foo"], ["@@bar", "f oo##bar", "foo#@#bar", "example.com#$#foo"], ["!foobar"]]);
260 test.deepEqual(changes, [], "Received changes"); 265 test.deepEqual(changes, [], "Received changes");
261 266
262 subscription1.disabled = true; 267 subscription1.disabled = true;
263 268
264 changes = []; 269 changes = [];
265 FilterStorage.addFilter(Filter.fromText("foo")); 270 FilterStorage.addFilter(Filter.fromText("foo"));
266 compareFiltersList(test, "Adding filter already in a disabled subscription", [ ["foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["!foobar", "foo"]]); 271 compareFiltersList(test, "Adding filter already in a disabled subscription", [ ["foo"], ["@@bar", "foo##bar", "foo#@#bar", "example.com#$#foo"], ["!foobar", "f oo"]]);
267 test.deepEqual(changes, ["filter.added foo"], "Received changes"); 272 test.deepEqual(changes, ["filter.added foo"], "Received changes");
268 273
269 changes = []; 274 changes = [];
270 FilterStorage.addFilter(Filter.fromText("foo"), subscription1); 275 FilterStorage.addFilter(Filter.fromText("foo"), subscription1);
271 compareFiltersList(test, "Adding filter to an explicit subscription", [["foo", "foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["!foobar", "foo"]]); 276 compareFiltersList(test, "Adding filter to an explicit subscription", [["foo", "foo"], ["@@bar", "foo##bar", "foo#@#bar", "example.com#$#foo"], ["!foobar", "f oo"]]);
272 test.deepEqual(changes, ["filter.added foo"], "Received changes"); 277 test.deepEqual(changes, ["filter.added foo"], "Received changes");
273 278
274 changes = []; 279 changes = [];
275 FilterStorage.addFilter(Filter.fromText("!foobar"), subscription2, 0); 280 FilterStorage.addFilter(Filter.fromText("!foobar"), subscription2, 0);
276 compareFiltersList(test, "Adding filter to an explicit subscription with posit ion", [["foo", "foo"], ["!foobar", "@@bar", "foo##bar", "foo#@#bar"], ["!foobar" , "foo"]]); 281 compareFiltersList(test, "Adding filter to an explicit subscription with posit ion", [["foo", "foo"], ["!foobar", "@@bar", "foo##bar", "foo#@#bar", "example.co m#$#foo"], ["!foobar", "foo"]]);
277 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); 282 test.deepEqual(changes, ["filter.added !foobar"], "Received changes");
278 283
279 test.done(); 284 test.done();
280 }; 285 };
281 286
282 exports.testRemovingFilters = function(test) 287 exports.testRemovingFilters = function(test)
283 { 288 {
284 let subscription1 = Subscription.fromURL("~foo"); 289 let subscription1 = Subscription.fromURL("~foo");
285 subscription1.filters = [Filter.fromText("foo"), Filter.fromText("foo"), Filte r.fromText("bar")]; 290 subscription1.filters = [Filter.fromText("foo"), Filter.fromText("foo"), Filte r.fromText("bar")];
286 291
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 compareFilterSubscriptions(test, "filter3 subscriptions after updating http:// test3/ filters", filter3, [subscription2]); 496 compareFilterSubscriptions(test, "filter3 subscriptions after updating http:// test3/ filters", filter3, [subscription2]);
492 497
493 FilterStorage.removeSubscription(subscription3); 498 FilterStorage.removeSubscription(subscription3);
494 499
495 compareFilterSubscriptions(test, "filter1 subscriptions after removing http:// test3/", filter1, []); 500 compareFilterSubscriptions(test, "filter1 subscriptions after removing http:// test3/", filter1, []);
496 compareFilterSubscriptions(test, "filter2 subscriptions after removing http:// test3/", filter2, [subscription2]); 501 compareFilterSubscriptions(test, "filter2 subscriptions after removing http:// test3/", filter2, [subscription2]);
497 compareFilterSubscriptions(test, "filter3 subscriptions after removing http:// test3/", filter3, [subscription2]); 502 compareFilterSubscriptions(test, "filter3 subscriptions after removing http:// test3/", filter3, [subscription2]);
498 503
499 test.done(); 504 test.done();
500 }; 505 };
OLDNEW
« no previous file with comments | « test/data/patterns.ini ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld