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

Unified Diff: test/filterListener.js

Issue 29912619: Issue 6891, 6741 - Rename FilterStorage to filterStorage (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Minor update Created Oct. 16, 2018, 10:02 p.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
« no previous file with comments | « lib/synchronizer.js ('k') | test/filterStorage.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/filterListener.js
===================================================================
--- a/test/filterListener.js
+++ b/test/filterListener.js
@@ -15,17 +15,17 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
const {createSandbox} = require("./_common");
let sandboxedRequire = null;
-let FilterStorage = null;
+let filterStorage = null;
let Subscription = null;
let Filter = null;
let defaultMatcher = null;
let SpecialSubscription = null;
exports.setUp = function(callback)
{
sandboxedRequire = createSandbox({
@@ -37,25 +37,25 @@
}
});
// We need to require the filterListener module so that filter changes will be
// noticed, even though we don't directly use the module here.
sandboxedRequire("../lib/filterListener");
(
- {FilterStorage} = sandboxedRequire("../lib/filterStorage"),
+ {filterStorage} = sandboxedRequire("../lib/filterStorage"),
{Subscription, SpecialSubscription} = sandboxedRequire("../lib/subscriptionClasses"),
{Filter} = sandboxedRequire("../lib/filterClasses"),
{defaultMatcher} = sandboxedRequire("../lib/matcher")
);
- FilterStorage.addSubscription(Subscription.fromURL("~fl~"));
- FilterStorage.addSubscription(Subscription.fromURL("~wl~"));
- FilterStorage.addSubscription(Subscription.fromURL("~eh~"));
+ filterStorage.addSubscription(Subscription.fromURL("~fl~"));
+ filterStorage.addSubscription(Subscription.fromURL("~wl~"));
+ filterStorage.addSubscription(Subscription.fromURL("~eh~"));
Subscription.fromURL("~fl~").defaults = ["blocking"];
Subscription.fromURL("~wl~").defaults = ["whitelist"];
Subscription.fromURL("~eh~").defaults = ["elemhide"];
callback();
};
@@ -117,38 +117,38 @@
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 filter6 = Filter.fromText("example.com#?#:-abp-properties(filter6')");
let filter7 = Filter.fromText("example.com#@#[-abp-properties='filter7']");
- FilterStorage.addFilter(filter1);
+ filterStorage.addFilter(filter1);
checkKnownFilters(test, "add filter1", {blacklist: [filter1.text]});
- FilterStorage.addFilter(filter2);
+ filterStorage.addFilter(filter2);
checkKnownFilters(test, "add @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
- FilterStorage.addFilter(filter3);
+ filterStorage.addFilter(filter3);
checkKnownFilters(test, "add ##filter3", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text]});
- FilterStorage.addFilter(filter4);
+ filterStorage.addFilter(filter4);
checkKnownFilters(test, "add !filter4", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text]});
- FilterStorage.addFilter(filter5);
+ filterStorage.addFilter(filter5);
checkKnownFilters(test, "add #@#filter5", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text]});
- FilterStorage.addFilter(filter6);
+ filterStorage.addFilter(filter6);
checkKnownFilters(test, "add example.com##:-abp-properties(filter6)", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text], elemhideemulation: [filter6.text]});
- FilterStorage.addFilter(filter7);
+ filterStorage.addFilter(filter7);
checkKnownFilters(test, "add example.com#@#[-abp-properties='filter7']", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
- FilterStorage.removeFilter(filter1);
+ filterStorage.removeFilter(filter1);
checkKnownFilters(test, "remove filter1", {whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
filter2.disabled = true;
checkKnownFilters(test, "disable filter2", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
- FilterStorage.removeFilter(filter2);
+ filterStorage.removeFilter(filter2);
checkKnownFilters(test, "remove filter2", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
- FilterStorage.removeFilter(filter4);
+ filterStorage.removeFilter(filter4);
checkKnownFilters(test, "remove filter4", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
test.done();
};
exports.testDisablingEnablingFiltersNotInTheList = function(test)
{
let filter1 = Filter.fromText("filter1");
@@ -200,133 +200,133 @@
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];
- FilterStorage.addSubscription(subscription);
+ 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);
+ filterStorage.addFilter(filter1);
checkKnownFilters(test, "add filter1", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
- FilterStorage.updateSubscriptionFilters(subscription, [filter4]);
+ filterStorage.updateSubscriptionFilters(subscription, [filter4]);
checkKnownFilters(test, "change subscription filters to filter4", {blacklist: [filter1.text]});
- FilterStorage.removeFilter(filter1);
+ filterStorage.removeFilter(filter1);
checkKnownFilters(test, "remove filter1", {});
- FilterStorage.updateSubscriptionFilters(subscription, [filter1, filter2]);
+ filterStorage.updateSubscriptionFilters(subscription, [filter1, filter2]);
checkKnownFilters(test, "change subscription filters to filter1, filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
filter1.disabled = true;
checkKnownFilters(test, "disable filter1", {whitelist: [filter2.text]});
filter2.disabled = true;
checkKnownFilters(test, "disable filter2", {});
filter1.disabled = false;
filter2.disabled = false;
checkKnownFilters(test, "enable filter1, filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
- FilterStorage.addFilter(filter1);
+ filterStorage.addFilter(filter1);
checkKnownFilters(test, "add filter1", {blacklist: [filter1.text], whitelist: [filter2.text]});
subscription.disabled = true;
checkKnownFilters(test, "disable subscription", {blacklist: [filter1.text]});
- FilterStorage.removeSubscription(subscription);
+ filterStorage.removeSubscription(subscription);
checkKnownFilters(test, "remove subscription", {blacklist: [filter1.text]});
- FilterStorage.addSubscription(subscription);
+ filterStorage.addSubscription(subscription);
checkKnownFilters(test, "add subscription", {blacklist: [filter1.text]});
subscription.disabled = false;
checkKnownFilters(test, "enable subscription", {blacklist: [filter1.text], whitelist: [filter2.text]});
subscription.disabled = true;
checkKnownFilters(test, "disable subscription", {blacklist: [filter1.text]});
- FilterStorage.addFilter(filter2);
+ filterStorage.addFilter(filter2);
checkKnownFilters(test, "add filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
- FilterStorage.removeFilter(filter2);
+ filterStorage.removeFilter(filter2);
checkKnownFilters(test, "remove filter2", {blacklist: [filter1.text]});
subscription.disabled = false;
checkKnownFilters(test, "enable subscription", {blacklist: [filter1.text], whitelist: [filter2.text]});
- FilterStorage.removeSubscription(subscription);
+ filterStorage.removeSubscription(subscription);
checkKnownFilters(test, "remove subscription", {blacklist: [filter1.text]});
test.done();
};
exports.testFilterGroupOperations = function(test)
{
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];
- FilterStorage.addSubscription(subscription);
- FilterStorage.addFilter(filter1);
+ 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]});
- FilterStorage.removeSubscription(subscription);
+ filterStorage.removeSubscription(subscription);
checkKnownFilters(test, "remove subscription", {});
subscription2.disabled = false;
checkKnownFilters(test, "enable blocking filters", {blacklist: [filter1.text]});
let subscription3 = Subscription.fromURL("~wl~");
subscription3.disabled = true;
checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text]});
- FilterStorage.addFilter(filter2);
+ filterStorage.addFilter(filter2);
checkKnownFilters(test, "add @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
test.equal(filter2.subscriptionCount, 1, "@@filter2.subscriptionCount");
test.ok([...filter2.subscriptions()][0] instanceof SpecialSubscription, "@@filter2 added to a new filter group");
test.ok([...filter2.subscriptions()][0] != subscription3, "@@filter2 filter group is not the disabled exceptions group");
subscription3.disabled = false;
checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]});
- FilterStorage.removeFilter(filter2);
- FilterStorage.addFilter(filter2);
+ filterStorage.removeFilter(filter2);
+ filterStorage.addFilter(filter2);
checkKnownFilters(test, "re-add @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
test.equal(filter2.subscriptionCount, 1, "@@filter2.subscriptionCount");
test.ok([...filter2.subscriptions()][0] == subscription3, "@@filter2 added to the default exceptions group");
let subscription4 = Subscription.fromURL("http://test/");
- FilterStorage.updateSubscriptionFilters(subscription4, [filter3, filter4, filter5]);
+ filterStorage.updateSubscriptionFilters(subscription4, [filter3, filter4, filter5]);
checkKnownFilters(test, "update subscription not in the list yet", {blacklist: [filter1.text], whitelist: [filter2.text]});
- FilterStorage.addSubscription(subscription4);
+ filterStorage.addSubscription(subscription4);
checkKnownFilters(test, "add subscription to the list", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text, filter4.text]});
- FilterStorage.updateSubscriptionFilters(subscription4, [filter3, filter2, filter5]);
+ filterStorage.updateSubscriptionFilters(subscription4, [filter3, filter2, filter5]);
checkKnownFilters(test, "update subscription while in the list", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]});
subscription3.disabled = true;
checkKnownFilters(test, "disable exception rules", {blacklist: [filter1.text, filter3.text], whitelist: [filter2.text]});
- FilterStorage.removeSubscription(subscription4);
+ filterStorage.removeSubscription(subscription4);
checkKnownFilters(test, "remove subscription from the list", {blacklist: [filter1.text]});
subscription3.disabled = false;
checkKnownFilters(test, "enable exception rules", {blacklist: [filter1.text], whitelist: [filter2.text]});
test.done();
};
@@ -334,32 +334,32 @@
{
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];
- FilterStorage.addSubscription(subscription1);
+ filterStorage.addSubscription(subscription1);
checkKnownFilters(test, "add subscription with filter1 and filter2", {});
let subscription2 = Subscription.fromURL("http://test2/");
subscription2.type = "circumvention";
subscription2.filters = [filter1];
- FilterStorage.addSubscription(subscription2);
+ filterStorage.addSubscription(subscription2);
checkKnownFilters(test, "add subscription of type circumvention with filter1", {snippets: [filter1.text]});
let subscription3 = Subscription.fromURL("~foo");
subscription3.filters = [filter2];
- FilterStorage.addSubscription(subscription3);
+ 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];
- FilterStorage.addSubscription(subscription4);
+ filterStorage.addSubscription(subscription4);
checkKnownFilters(test, "add ABP anti-circumvention subscription with filter3", {snippets: [filter1.text, filter2.text, filter3.text]});
test.done();
};
« no previous file with comments | « lib/synchronizer.js ('k') | test/filterStorage.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld