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

Unified Diff: test/filterListener.js

Issue 29934588: Issue 7094 - Encapsulate management of subscription filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Lazy initialize and clean up filter text lookup Created Nov. 18, 2018, 2:20 a.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
Index: test/filterListener.js
===================================================================
--- a/test/filterListener.js
+++ b/test/filterListener.js
@@ -202,17 +202,23 @@
filter2.disabled = true;
let filter3 = Filter.fromText("##filter3");
let filter4 = Filter.fromText("!filter4");
let filter5 = Filter.fromText("#@#filter5");
let filter6 = Filter.fromText("example.com#?#:-abp-properties(filter6)");
let filter7 = Filter.fromText("example.com#@#[-abp-properties='filter7']");
let subscription = Subscription.fromURL("http://test1/");
- subscription.filters = [filter1, filter2, filter3, filter4, filter5, filter6, filter7];
+ subscription.addFilter(filter1);
+ subscription.addFilter(filter2);
+ subscription.addFilter(filter3);
+ subscription.addFilter(filter4);
+ subscription.addFilter(filter5);
+ subscription.addFilter(filter6);
+ subscription.addFilter(filter7);
filterStorage.addSubscription(subscription);
checkKnownFilters(test, "add subscription with filter1, @@filter2, ##filter3, !filter4, #@#filter5, example.com#?#:-abp-properties(filter6), example.com#@#[-abp-properties='filter7']", {blacklist: [filter1.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
filter2.disabled = false;
checkKnownFilters(test, "enable @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
filterStorage.addFilter(filter1);
@@ -272,17 +278,18 @@
{
let filter1 = Filter.fromText("filter1");
let filter2 = Filter.fromText("@@filter2");
let filter3 = Filter.fromText("filter3");
let filter4 = Filter.fromText("@@filter4");
let filter5 = Filter.fromText("!filter5");
let subscription = Subscription.fromURL("http://test1/");
- subscription.filters = [filter1, filter2];
+ subscription.addFilter(filter1);
+ subscription.addFilter(filter2);
filterStorage.addSubscription(subscription);
filterStorage.addFilter(filter1);
checkKnownFilters(test, "initial setup", {blacklist: [filter1.text], whitelist: [filter2.text]});
let subscription2 = Subscription.fromURL("~fl~");
subscription2.disabled = true;
checkKnownFilters(test, "disable blocking filters", {blacklist: [filter1.text], whitelist: [filter2.text]});
@@ -336,34 +343,35 @@
exports.testSnippetFilters = function(test)
{
let filter1 = Filter.fromText("example.com#$#filter1");
let filter2 = Filter.fromText("example.com#$#filter2");
let filter3 = Filter.fromText("example.com#$#filter3");
let subscription1 = Subscription.fromURL("http://test1/");
- subscription1.filters = [filter1, filter2];
+ subscription1.addFilter(filter1);
+ subscription1.addFilter(filter2);
filterStorage.addSubscription(subscription1);
checkKnownFilters(test, "add subscription with filter1 and filter2", {});
let subscription2 = Subscription.fromURL("http://test2/");
subscription2.type = "circumvention";
- subscription2.filters = [filter1];
+ subscription2.addFilter(filter1);
filterStorage.addSubscription(subscription2);
checkKnownFilters(test, "add subscription of type circumvention with filter1", {snippets: [filter1.text]});
let subscription3 = Subscription.fromURL("~foo");
- subscription3.filters = [filter2];
+ subscription3.addFilter(filter2);
filterStorage.addSubscription(subscription3);
checkKnownFilters(test, "add special subscription with filter2", {snippets: [filter1.text, filter2.text]});
let subscription4 = Subscription.fromURL("https://easylist-downloads.adblockplus.org/abp-filters-anti-cv.txt");
- subscription4.filters = [filter3];
+ subscription4.addFilter(filter3);
filterStorage.addSubscription(subscription4);
checkKnownFilters(test, "add ABP anti-circumvention subscription with filter3", {snippets: [filter1.text, filter2.text, filter3.text]});
test.done();
};

Powered by Google App Engine
This is Rietveld