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

Unified Diff: test/elemHide.js

Issue 29853558: Noissue - Delete element hiding domain entry once all filters removed (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Rebase, add tests Created Aug. 15, 2018, 10:13 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
@@ -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();
+};
« 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