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

Unified Diff: test/elemHide.js

Issue 29886555: Issue 6957 - Add generateStyleSheetForDomain function to ElemHide module (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase, remove getSelectorsForDomain Created Sept. 27, 2018, 3:55 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/elemHide.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/elemHide.js
===================================================================
--- a/test/elemHide.js
+++ b/test/elemHide.js
@@ -40,35 +40,42 @@
{Filter} = sandboxedRequire("../lib/filterClasses")
);
callback();
};
function normalizeSelectors(selectors)
{
- // getSelectorsForDomain is currently allowed to return duplicate selectors
- // for performance reasons, so we need to remove duplicates here.
- return selectors.sort().filter((selector, index, sortedSelectors) =>
+ // generateStyleSheetForDomain is currently allowed to return duplicate
+ // selectors for performance reasons, so we need to remove duplicates here.
+ return selectors.slice().sort().filter((selector, index, sortedSelectors) =>
{
return index == 0 || selector != sortedSelectors[index - 1];
});
}
function testResult(test, domain, expectedSelectors, specificOnly)
{
let normalizedExpectedSelectors = normalizeSelectors(expectedSelectors);
- test.deepEqual(
- normalizeSelectors(ElemHide.getSelectorsForDomain(domain, specificOnly)),
- normalizedExpectedSelectors
- );
+ let {code, selectors} =
+ ElemHide.generateStyleSheetForDomain(domain, specificOnly);
+
+ test.deepEqual(normalizeSelectors(selectors), normalizedExpectedSelectors);
+
+ // Make sure each expected selector is in the actual CSS code.
+ for (let selector of normalizedExpectedSelectors)
+ {
+ test.ok(code.includes(selector + ", ") ||
+ code.includes(selector + " {display: none !important;}\n"));
+ }
}
-exports.testGetSelectorsForDomain = function(test)
+exports.testGenerateStyleSheetForDomain = function(test)
{
let addFilter = filterText => ElemHide.add(Filter.fromText(filterText));
let removeFilter = filterText => ElemHide.remove(Filter.fromText(filterText));
let addException =
filterText => ElemHideExceptions.add(Filter.fromText(filterText));
let removeException =
filterText => ElemHideExceptions.remove(Filter.fromText(filterText));
« no previous file with comments | « lib/elemHide.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld