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

Unified Diff: test/filterListener.js

Issue 29824589: Issue 6538, 6781 - Allow snippets only from circumvention lists (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Improve unit tests Created July 10, 2018, 7:15 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
« lib/filterListener.js ('K') | « lib/filterListener.js ('k') | no next file » | 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
@@ -27,17 +27,18 @@
let SpecialSubscription = null;
let ElemHideException = null;
exports.setUp = function(callback)
{
sandboxedRequire = createSandbox({
extraExports: {
elemHide: ["knownFilters"],
- elemHideEmulation: ["filters"]
+ elemHideEmulation: ["filters"],
+ snippets: ["filters"]
}
});
// 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");
(
@@ -89,18 +90,23 @@
result.elemhide.push(filter.text);
}
let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
result.elemhideemulation = [];
for (let filterText of elemHideEmulation.filters)
result.elemhideemulation.push(filterText);
+ let snippets = sandboxedRequire("../lib/snippets");
+ result.snippets = [];
+ for (let filterText of snippets.filters)
+ result.snippets.push(filterText);
+
let types = ["blacklist", "whitelist", "elemhide", "elemhideexception",
- "elemhideemulation"];
+ "elemhideemulation", "snippets"];
for (let type of types)
{
if (!(type in expected))
expected[type] = [];
else
expected[type].sort();
result[type].sort();
}
@@ -320,8 +326,35 @@
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();
};
+
+exports.testSnippetFilters = function(test)
+{
+ let filter1 = Filter.fromText("example.com#$#filter1");
+ let filter2 = Filter.fromText("example.com#$#filter2");
+
+ let subscription1 = Subscription.fromURL("http://test1/");
+ subscription1.filters = [filter1, filter2];
+
+ 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);
+ checkKnownFilters(test, "add subscription of type circumvention with filter1", {snippets: [filter1.text]});
+
+ let subscription3 = Subscription.fromURL("~foo");
+ subscription3.filters = [filter2];
+
+ FilterStorage.addSubscription(subscription3);
+ checkKnownFilters(test, "add special subscription with filter2", {snippets: [filter1.text, filter2.text]});
+
+ test.done();
+};
« lib/filterListener.js ('K') | « lib/filterListener.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld