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

Unified Diff: test/snippets.js

Issue 29849575: Issue 6797 - Require active domains in snippet filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Add tests Created Aug. 7, 2018, 2:49 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/filterClasses.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/snippets.js
===================================================================
--- a/test/snippets.js
+++ b/test/snippets.js
@@ -20,42 +20,55 @@
"use strict";
const {createSandbox} = require("./_common");
let Snippets = null;
let parseScript = null;
let compileScript = null;
let Filter = null;
+let SnippetFilter = null;
exports.setUp = function(callback)
{
let sandboxedRequire = createSandbox();
(
- {Filter} = sandboxedRequire("../lib/filterClasses"),
+ {Filter, SnippetFilter} = sandboxedRequire("../lib/filterClasses"),
{Snippets, parseScript, compileScript} = sandboxedRequire("../lib/snippets")
);
callback();
};
exports.testDomainRestrictions = function(test)
{
function testScriptMatches(description, filters, domain, expectedMatches)
{
- for (let filter of filters)
- Snippets.add(Filter.fromText(filter));
+ for (let filter of filters.map(Filter.fromText))
+ {
+ if (filter instanceof SnippetFilter)
+ Snippets.add(filter);
+ }
let matches = Snippets.getScriptsForDomain(domain);
test.deepEqual(matches.sort(), expectedMatches.sort(), description);
Snippets.clear();
}
testScriptMatches(
+ "Ignore generic filters",
+ [
+ "#$#foo", "example.com#$#foo",
kzar 2018/08/08 11:31:50 Shouldn't we use different snippet names for these
Manish Jethani 2018/08/08 13:56:42 Thanks, this makes sense. Done.
+ "~example.com#$#foo"
+ ],
+ "example.com",
+ ["foo"]
+ );
+ testScriptMatches(
"Ignore filters that include parent domain but exclude subdomain",
[
"~www.example.com,example.com#$#foo"
],
"www.example.com",
[]
);
testScriptMatches(
« no previous file with comments | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld