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

Unified Diff: test/elemHideEmulation.js

Issue 29361668: Issue 4394 - Create a filter class for element hiding emulation filters (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Patch Set: Address Wladimir's comments Created Nov. 21, 2016, 2:34 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
Index: test/elemHideEmulation.js
===================================================================
rename from test/cssRules.js
rename to test/elemHideEmulation.js
--- a/test/cssRules.js
+++ b/test/elemHideEmulation.js
@@ -14,50 +14,52 @@
* You should have received a copy of the GNU General Public License
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
"use strict";
let {createSandbox} = require("./_common");
-let CSSPropertyFilter = null;
-let CSSRules = null;
+let ElemHideEmulationFilter = null;
+let ElemHideEmulation = null;
let ElemHide = null;
let Filter = null;
exports.setUp = function(callback)
{
let sandboxedRequire = createSandbox();
(
- {Filter, CSSPropertyFilter} = sandboxedRequire("../lib/filterClasses"),
- {CSSRules} = sandboxedRequire("../lib/cssRules"),
+ {Filter,
+ ElemHideEmulationFilter} = sandboxedRequire("../lib/filterClasses"),
+ {ElemHideEmulation} = sandboxedRequire("../lib/elemHideEmulation"),
{ElemHide} = sandboxedRequire("../lib/elemHide")
);
callback();
};
exports.testDomainRestrictions = function(test)
{
function testSelectorMatches(description, filters, domain, expectedMatches)
{
for (let filter of filters)
{
filter = Filter.fromText(filter);
- if (filter instanceof CSSPropertyFilter)
- CSSRules.add(filter);
+ if (filter instanceof ElemHideEmulationFilter)
+ ElemHideEmulation.add(filter);
else
ElemHide.add(filter);
}
- let matches = CSSRules.getRulesForDomain(domain).map(filter => filter.text);
+ let matches = ElemHideEmulation.getRulesForDomain(domain)
+ .map(filter => filter.text);
test.deepEqual(matches.sort(), expectedMatches.sort(), description);
- CSSRules.clear();
+ ElemHideEmulation.clear();
ElemHide.clear();
}
testSelectorMatches(
"Ignore generic filters",
["##[-abp-properties='foo']", "example.com##[-abp-properties='foo']",
"~example.com##[-abp-properties='foo']"],
"example.com",
@@ -90,47 +92,47 @@
"other.example.com##[-abp-properties='foo']"],
"other.example.com",
["other.example.com##[-abp-properties='foo']"]
);
test.done();
};
-exports.testCSSPropertyFiltersContainer = function(test)
+exports.testElemHideEmulationFiltersContainer = function(test)
{
function compareRules(description, domain, expectedMatches)
{
- let result = CSSRules.getRulesForDomain(domain)
+ let result = ElemHideEmulation.getRulesForDomain(domain)
.map((filter) => filter.text);
expectedMatches = expectedMatches.map(filter => filter.text);
test.deepEqual(result.sort(), expectedMatches.sort(), description);
}
let domainFilter = Filter.fromText("example.com##filter1");
let subdomainFilter = Filter.fromText("www.example.com##filter2");
let otherDomainFilter = Filter.fromText("other.example.com##filter3");
- CSSRules.add(domainFilter);
- CSSRules.add(subdomainFilter);
- CSSRules.add(otherDomainFilter);
+ ElemHideEmulation.add(domainFilter);
+ ElemHideEmulation.add(subdomainFilter);
+ ElemHideEmulation.add(otherDomainFilter);
compareRules(
"Return all matching filters",
"www.example.com",
[domainFilter, subdomainFilter]
);
- CSSRules.remove(domainFilter);
+ ElemHideEmulation.remove(domainFilter);
compareRules(
"Return all matching filters after removing one",
"www.example.com",
[subdomainFilter]
);
- CSSRules.clear();
+ ElemHideEmulation.clear();
compareRules(
"Return no filters after clearing",
"www.example.com",
[]
);
test.done();
};

Powered by Google App Engine
This is Rietveld