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

Unified Diff: test/elemHide.js

Issue 29783618: Issue 6665 - Split out element hiding exceptions into their own module (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add lib/elemHideExceptions.js Created Aug. 7, 2018, 2:18 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/filterListener.js ('k') | test/elemHideEmulation.js » ('j') | 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
@@ -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"]);
@@ -188,24 +194,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"]);
@@ -230,13 +236,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();
};
« no previous file with comments | « lib/filterListener.js ('k') | test/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld