| 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( |