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