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: Use different snippets names Created Aug. 8, 2018, 1:55 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,57 +20,70 @@
"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-1", "example.com#$#foo-2",
+ "~example.com#$#foo-3"
+ ],
+ "example.com",
+ ["foo-2"]
+ );
+ testScriptMatches(
"Ignore filters that include parent domain but exclude subdomain",
[
"~www.example.com,example.com#$#foo"
],
"www.example.com",
[]
);
testScriptMatches(
"Ignore filters for other subdomain",
[
- "www.example.com#$#foo",
- "other.example.com#$#foo"
+ "www.example.com#$#foo-1",
+ "other.example.com#$#foo-2"
],
"other.example.com",
- ["foo"]
+ ["foo-2"]
);
test.done();
};
exports.testSnippetFiltersContainer = function(test)
{
function compareRules(description, domain, expectedMatches)
« 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