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(); |
+}; |