Index: test/elemHide.js |
=================================================================== |
--- a/test/elemHide.js |
+++ b/test/elemHide.js |
@@ -15,23 +15,25 @@ |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
"use strict"; |
const {createSandbox} = require("./_common"); |
let ElemHide = null; |
+let ElemHideExceptions = null; |
let Filter = null; |
exports.setUp = function(callback) |
{ |
let sandboxedRequire = createSandbox(); |
( |
{ElemHide} = sandboxedRequire("../lib/elemHide"), |
+ {ElemHideExceptions} = sandboxedRequire("../lib/elemHideExceptions"), |
{Filter} = sandboxedRequire("../lib/filterClasses") |
); |
callback(); |
}; |
function normalizeSelectors(selectors) |
{ |
@@ -52,16 +54,20 @@ |
normalizedExpectedSelectors |
); |
} |
exports.testGetSelectorsForDomain = 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)); |
testResult(test, "", []); |
addFilter("~foo.example.com,example.com##foo"); |
testResult(test, "barfoo.example.com", ["foo"]); |
testResult(test, "bar.foo.example.com", []); |
testResult(test, "foo.example.com", []); |
testResult(test, "example.com", ["foo"]); |
@@ -69,41 +75,41 @@ |
testResult(test, "", []); |
addFilter("foo.example.com##turnip"); |
testResult(test, "foo.example.com", ["turnip"]); |
testResult(test, "example.com", ["foo"]); |
testResult(test, "com", []); |
testResult(test, "", []); |
- addFilter("example.com#@#foo"); |
+ addException("example.com#@#foo"); |
testResult(test, "foo.example.com", ["turnip"]); |
testResult(test, "example.com", []); |
testResult(test, "com", []); |
testResult(test, "", []); |
addFilter("com##bar"); |
testResult(test, "foo.example.com", ["turnip", "bar"]); |
testResult(test, "example.com", ["bar"]); |
testResult(test, "com", ["bar"]); |
testResult(test, "", []); |
- addFilter("example.com#@#bar"); |
+ addException("example.com#@#bar"); |
testResult(test, "foo.example.com", ["turnip"]); |
testResult(test, "example.com", []); |
testResult(test, "com", ["bar"]); |
testResult(test, "", []); |
- removeFilter("example.com#@#foo"); |
+ removeException("example.com#@#foo"); |
testResult(test, "foo.example.com", ["turnip"]); |
testResult(test, "example.com", ["foo"]); |
testResult(test, "com", ["bar"]); |
testResult(test, "", []); |
- removeFilter("example.com#@#bar"); |
+ removeException("example.com#@#bar"); |
testResult(test, "foo.example.com", ["turnip", "bar"]); |
testResult(test, "example.com", ["foo", "bar"]); |
testResult(test, "com", ["bar"]); |
testResult(test, "", []); |
addFilter("##generic"); |
testResult(test, "foo.example.com", ["turnip", "bar", "generic"]); |
testResult(test, "example.com", ["foo", "bar", "generic"]); |
@@ -186,24 +192,24 @@ |
addFilter("##hello"); |
testResult(test, "foo.com", [], true); |
testResult(test, "foo.com", ["hello"], false); |
testResult(test, "foo.com", ["hello"]); |
testResult(test, "bar.com", [], true); |
testResult(test, "bar.com", ["hello"], false); |
testResult(test, "bar.com", ["hello"]); |
- addFilter("foo.com#@#hello"); |
+ addException("foo.com#@#hello"); |
testResult(test, "foo.com", [], true); |
testResult(test, "foo.com", [], false); |
testResult(test, "foo.com", []); |
testResult(test, "bar.com", [], true); |
testResult(test, "bar.com", ["hello"], false); |
testResult(test, "bar.com", ["hello"]); |
- removeFilter("foo.com#@#hello"); |
+ removeException("foo.com#@#hello"); |
testResult(test, "foo.com", [], true); |
// Note: We don't take care to track conditional selectors which became |
// unconditional when a filter was removed. This was too expensive. |
testResult(test, "foo.com", ["hello"], false); |
testResult(test, "foo.com", ["hello"]); |
testResult(test, "bar.com", [], true); |
testResult(test, "bar.com", ["hello"], false); |
testResult(test, "bar.com", ["hello"]); |
@@ -228,13 +234,13 @@ |
testResult(test, "foo.com", []); |
test.done(); |
}; |
exports.testZeroFilterKey = function(test) |
{ |
ElemHide.add(Filter.fromText("##test")); |
- ElemHide.add(Filter.fromText("foo.com#@#test")); |
+ ElemHideExceptions.add(Filter.fromText("foo.com#@#test")); |
testResult(test, "foo.com", []); |
testResult(test, "bar.com", ["test"]); |
test.done(); |
}; |