Index: test/elemHide.js |
=================================================================== |
--- a/test/elemHide.js |
+++ b/test/elemHide.js |
@@ -17,22 +17,27 @@ |
"use strict"; |
const {createSandbox} = require("./_common"); |
let ElemHide = null; |
let ElemHideExceptions = null; |
let Filter = null; |
+let filtersByDomain = null; |
exports.setUp = function(callback) |
{ |
- let sandboxedRequire = createSandbox(); |
+ let sandboxedRequire = createSandbox({ |
+ extraExports: { |
+ elemHide: ["filtersByDomain"] |
+ } |
+ }); |
( |
- {ElemHide} = sandboxedRequire("../lib/elemHide"), |
+ {ElemHide, filtersByDomain} = sandboxedRequire("../lib/elemHide"), |
{ElemHideExceptions} = sandboxedRequire("../lib/elemHideExceptions"), |
{Filter} = sandboxedRequire("../lib/filterClasses") |
); |
callback(); |
}; |
function normalizeSelectors(selectors) |
@@ -241,8 +246,30 @@ |
exports.testZeroFilterKey = function(test) |
{ |
ElemHide.add(Filter.fromText("##test")); |
ElemHideExceptions.add(Filter.fromText("foo.com#@#test")); |
testResult(test, "foo.com", []); |
testResult(test, "bar.com", ["test"]); |
test.done(); |
}; |
+ |
+exports.testFiltersByDomain = function(test) |
+{ |
+ test.equal(filtersByDomain.size, 0); |
+ |
+ ElemHide.add(Filter.fromText("##test")); |
+ test.equal(filtersByDomain.size, 0); |
+ |
+ ElemHide.add(Filter.fromText("example.com##test")); |
+ test.equal(filtersByDomain.size, 1); |
+ |
+ ElemHide.add(Filter.fromText("example.com,~www.example.com##test")); |
+ test.equal(filtersByDomain.size, 2); |
+ |
+ ElemHide.remove(Filter.fromText("example.com##test")); |
+ test.equal(filtersByDomain.size, 2); |
+ |
+ ElemHide.remove(Filter.fromText("example.com,~www.example.com##test")); |
+ test.equal(filtersByDomain.size, 0); |
+ |
+ test.done(); |
+}; |