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

Unified Diff: test/filterListener.js

Issue 29361668: Issue 4394 - Create a filter class for element hiding emulation filters (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Patch Set: Created Nov. 3, 2016, 3:42 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
« test/filterClasses.js ('K') | « test/filterClasses.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
@@ -26,17 +26,17 @@
let defaultMatcher = null;
let SpecialSubscription = null;
exports.setUp = function(callback)
{
sandboxedRequire = createSandbox({
extraExports: {
elemHide: ["filterByKey", "exceptions"],
- cssRules: ["filters"]
+ elemHideEmulation: ["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");
(
@@ -86,23 +86,23 @@
result.elemhideexception = [];
for (let selector in elemHide.exceptions)
{
let list = elemHide.exceptions[selector];
for (let exception of list)
result.elemhideexception.push(exception.text);
}
- let cssRules = sandboxedRequire("../lib/cssRules");
- result.cssrule = [];
- for (let filterText in cssRules.filters)
- result.cssrule.push(filterText);
+ let elemHideEmulation = sandboxedRequire("../lib/elemHideEmulation");
+ result.elemhideemulation = [];
+ for (let filterText in elemHideEmulation.filters)
+ result.elemhideemulation.push(filterText);
let types = ["blacklist", "whitelist", "elemhide", "elemhideexception",
- "cssrule"];
+ "elemhideemulation"];
for (let type of types)
{
if (!(type in expected))
expected[type] = [];
else
expected[type].sort();
result[type].sort();
}
@@ -126,28 +126,28 @@
checkKnownFilters(test, "add @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text]});
FilterStorage.addFilter(filter3);
checkKnownFilters(test, "add #filter3", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text]});
FilterStorage.addFilter(filter4);
checkKnownFilters(test, "add !filter4", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text]});
FilterStorage.addFilter(filter5);
checkKnownFilters(test, "add #@#filter5", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text]});
FilterStorage.addFilter(filter6);
- checkKnownFilters(test, "add example.com##[-abp-properties='filter6']", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text], cssrule: [filter6.text]});
+ 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);
- checkKnownFilters(test, "add example.com#@#[-abp-properties='filter7']", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], cssrule: [filter6.text]});
+ 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);
- checkKnownFilters(test, "remove filter1", {whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], cssrule: [filter6.text]});
+ 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], cssrule: [filter6.text]});
+ checkKnownFilters(test, "disable filter2", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
FilterStorage.removeFilter(filter2);
- checkKnownFilters(test, "remove filter2", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], cssrule: [filter6.text]});
+ checkKnownFilters(test, "remove filter2", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
FilterStorage.removeFilter(filter4);
- checkKnownFilters(test, "remove filter4", {elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], cssrule: [filter6.text]});
+ 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");
let filter2 = Filter.fromText("@@filter2");
@@ -199,23 +199,23 @@
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);
- 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], cssrule: [filter6.text]});
+ 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], cssrule: [filter6.text]});
+ checkKnownFilters(test, "enable @@filter2", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], elemhideemulation: [filter6.text]});
FilterStorage.addFilter(filter1);
- checkKnownFilters(test, "add filter1", {blacklist: [filter1.text], whitelist: [filter2.text], elemhide: [filter3.text], elemhideexception: [filter5.text, filter7.text], cssrule: [filter6.text]});
+ 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]);
checkKnownFilters(test, "change subscription filters to filter4", {blacklist: [filter1.text]});
FilterStorage.removeFilter(filter1);
checkKnownFilters(test, "remove filter1", {});
FilterStorage.updateSubscriptionFilters(subscription, [filter1, filter2]);
« test/filterClasses.js ('K') | « test/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld