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

Unified Diff: test/elemHide.js

Issue 29349187: Issue 4167 - getSelectorsForDomain criteria + keys (Closed)
Patch Set: Only store one filter key per unconditional selector Created Sept. 19, 2016, 4:51 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
diff --git a/test/elemHide.js b/test/elemHide.js
index b93baa4e4400ec3a923fb6ad515e874206128154..76d3827c3fe209c243ac9163898a10c6fe3e7a05 100644
--- a/test/elemHide.js
+++ b/test/elemHide.js
@@ -41,10 +41,13 @@ exports.testGetSelectorsForDomain = function(test)
return index == 0 || selector != selectors[index - 1];
});
}
- function selectorsEqual(domain, expectedSelectors, specificOnly)
+ function selectorsEqual(domain, expectedSelectors, specificOnly,
+ noUnconditional, provideFilterKeys)
{
test.deepEqual(
- normalizeSelectors(ElemHide.getSelectorsForDomain(domain, specificOnly)),
+ normalizeSelectors(ElemHide.getSelectorsForDomain(
+ domain, specificOnly, noUnconditional, provideFilterKeys
+ )),
normalizeSelectors(expectedSelectors)
);
}
@@ -159,7 +162,37 @@ exports.testGetSelectorsForDomain = function(test)
selectorsEqual("example.com", ["foo"]);
selectorsEqual("com", ["foo"]);
selectorsEqual("", ["foo"]);
- removeFilter("example.org##foo");
+ removeFilter("~example.org##foo");
+
+ // Test specificOnly and noUnconditional
+ addFilter("~example.com##foo");
+ selectorsEqual("foo.com", [], true, false);
+ selectorsEqual("foo.com", ["foo"], false, true);
+ addFilter("foo.com##foo");
+ selectorsEqual("foo.com", ["foo"], true, false);
+ selectorsEqual("foo.com", ["foo"], false, true);
+ removeFilter("foo.com##foo");
+ removeFilter("~example.org##foo");
+
+ // Test provideFilterKeys
+ addFilter("~foo.com##nope");
+ addFilter("##foo");
+ addFilter("##bar");
+ addFilter("##hello");
+ addFilter("##world");
+ let selectorsWithKeys = ElemHide.getSelectorsForDomain("foo.com", false,
+ false, true);
+ let selectors = selectorsWithKeys[0];
+ let filterKeys = selectorsWithKeys[1];
+ test.deepEqual(filterKeys.map(k => ElemHide.getFilterByKey(k).selector),
+ selectors);
+ test.deepEqual(normalizeSelectors(selectors),
+ normalizeSelectors(["bar", "foo", "hello", "world"]));
+ removeFilter("##world");
+ removeFilter("##hello");
+ removeFilter("##bar");
+ removeFilter("##foo");
+ removeFilter("~foo.com##nope");
test.done();
};
« 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