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

Unified Diff: test/abp2blocklist.js

Issue 29467595: Issue 5325 - Add support for separator characters (Closed) Base URL: https://hg.adblockplus.org/abp2blocklist
Patch Set: Rebase Created July 12, 2017, 12:45 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/abp2blocklist.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/abp2blocklist.js
===================================================================
--- a/test/abp2blocklist.js
+++ b/test/abp2blocklist.js
@@ -76,33 +76,58 @@
testRules(test, ["test.com#@#whatever", "##whatever"], []);
testRules(test, ["~test.com##whatever"], []);
test.done();
},
testRequestFilters: function(test)
{
- testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [
- {trigger: {"url-filter": "^https?://.*/foo",
- "resource-type": ["image", "style-sheet", "script", "font",
- "media", "raw"]},
- action: {type: "block"}},
- {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com",
- "url-filter-is-case-sensitive": true,
- "resource-type": ["image", "style-sheet", "script", "font",
- "media", "raw", "document"],
- "unless-top-url": ["^https?://([^/]+\\.)?test\\.com"],
- "top-url-filter-is-case-sensitive": true},
- action: {type: "block"}},
- {trigger: {"url-filter": "http://example\\.com/foo",
- "resource-type": ["image", "style-sheet", "script", "font",
- "media", "raw", "document"],
- "unless-top-url": ["http://example\\.com/foo"]},
- action: {type: "block"}}
+ testRules(test, [
+ "/foo", "||test.com^", "http://example.com/foo", "^foo^"
+ ], [
+ {
+ trigger: {
+ "url-filter": "^https?://.*/foo",
+ "resource-type": ["image", "style-sheet", "script", "font",
+ "media", "raw"]
+ },
+ action: {type: "block"}
+ },
+ {
+ trigger: {
+ "url-filter": "^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$",
+ "url-filter-is-case-sensitive": true,
+ "resource-type": ["image", "style-sheet", "script", "font",
+ "media", "raw", "document"],
+ "unless-top-url": [
+ "^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$"
+ ],
+ "top-url-filter-is-case-sensitive": true
+ },
+ action: {type: "block"}
+ },
+ {
+ trigger: {
+ "url-filter": "http://example\\.com/foo",
+ "resource-type": ["image", "style-sheet", "script", "font",
+ "media", "raw", "document"],
+ "unless-top-url": ["http://example\\.com/foo"]
+ },
+ action: {type: "block"}
+ },
+ {
+ trigger: {
+ "url-filter":
+ "^https?://(.*[^-_.%A-Za-z0-9])?foo([^-_.%A-Za-z0-9].*)?$",
+ "resource-type": ["image", "style-sheet", "script", "font",
+ "media", "raw"]
+ },
+ action: {type: "block"}
+ }
]);
testRules(test, ["||example.com"], [
{trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
"url-filter-is-case-sensitive": true,
"resource-type": ["image", "style-sheet", "script", "font",
"media", "raw", "document"],
"unless-top-url": ["^https?://([^/]+\\.)?example\\.com"],
@@ -145,33 +170,50 @@
rules => rules.map(rule => rule.action.selector));
test.done();
},
testDomainWhitelisting: function(test)
{
testRules(test, ["@@||example.com^$document"], [
- {trigger: {"url-filter": ".*",
- "if-domain": ["*example.com"]},
- action: {type: "ignore-previous-rules"}}
+ {
+ trigger: {
+ "url-filter": ".*",
+ "if-domain": ["*example.com"]
+ },
+ action: {type: "ignore-previous-rules"}
+ }
]);
testRules(test, ["@@||example.com^$document,image"], [
- {trigger: {"url-filter": ".*",
- "if-domain": ["*example.com"]},
- action: {type: "ignore-previous-rules"}},
- {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
- "url-filter-is-case-sensitive": true,
- "resource-type": ["image"]},
- action: {type: "ignore-previous-rules"}}
+ {
+ trigger: {
+ "url-filter": ".*",
+ "if-domain": ["*example.com"]
+ },
+ action: {type: "ignore-previous-rules"}
+ },
+ {
+ trigger: {
+ "url-filter": "^https?://([^/]+\\.)?example\\.com([^-_.%a-z0-9].*)?$",
+ "url-filter-is-case-sensitive": true,
+ "resource-type": ["image"]
+ },
+ action: {type: "ignore-previous-rules"}
+ }
]);
testRules(test, ["@@||example.com/path^$font,document"], [
- {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path",
- "resource-type": ["font"]},
- action: {type: "ignore-previous-rules"}}
+ {
+ trigger: {
+ "url-filter":
+ "^https?://([^/]+\\.)?example\\.com/path([^-_.%A-Za-z0-9].*)?$",
+ "resource-type": ["font"]
+ },
+ action: {type: "ignore-previous-rules"}
+ }
]);
test.done();
},
testGenericblockExceptions: function(test)
{
testRules(test, ["^ad.jpg|", "@@||example.com^$genericblock"],
« no previous file with comments | « lib/abp2blocklist.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld