Index: test/abp2blocklist.js |
=================================================================== |
--- a/test/abp2blocklist.js |
+++ b/test/abp2blocklist.js |
@@ -57,19 +57,21 @@ |
// (4) exceptions for all rules. |
testRules(test, [ |
"##.whatever", |
"test.com###something", |
"@@||special.test.com^$elemhide", |
"@@||test.com^$generichide" |
], [ |
["^https?://", "css-display-none"], |
- ["^https?://([^/]+\\.)?test\\.com", "ignore-previous-rules"], |
+ ["^https?://([^/]+\\.)?test\\.com([^-_.%a-z0-9].*)?$", |
+ "ignore-previous-rules"], |
["^https?://([^/:]*\\.)?test\\.com[/:]", "css-display-none"], |
- ["^https?://([^/]+\\.)?special\\.test\\.com", "ignore-previous-rules"] |
+ ["^https?://([^/]+\\.)?special\\.test\\.com([^-_.%a-z0-9].*)?$", |
+ "ignore-previous-rules"] |
], rules => rules.map(rule => [rule.trigger["url-filter"], |
rule.action.type])); |
testRules(test, ["#@#whatever"], []); |
testRules(test, ["test.com#@#whatever"], []); |
testRules(test, ["~test.com#@#whatever"], []); |
// We currently completely ignore any element hiding filters that have the |
@@ -79,33 +81,38 @@ |
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"], [ |
+ testRules(test, ["/foo", "||test.com^", "http://example.com/foo", "^foo^"], [ |
{trigger: {"url-filter": "^https?://.*/foo", |
"resource-type": ["image", "style-sheet", "script", "font", |
"media", "raw", "document"], |
"unless-top-url": ["^https?://.*/foo"]}, |
action: {type: "block"}}, |
- {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com", |
+ {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"], |
+ "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", "document"], |
+ "unless-top-url": ["^https?://(.*[^-_.%A-Za-z0-9])?foo([^-_.%A-Za-z0-9].*)?$"]}, |
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"], |
@@ -157,23 +164,23 @@ |
{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", |
+ {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", |
+ {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path([^-_.%A-Za-z0-9].*)?$", |
kzar
2017/07/07 12:46:18
Nit: Mind fixing these long lines where possible?
Manish Jethani
2017/07/08 06:33:57
Acknowledged.
I'll try to fix this.
Manish Jethani
2017/07/09 10:50:52
Done.
|
"resource-type": ["font"]}, |
action: {type: "ignore-previous-rules"}} |
]); |
test.done(); |
}, |
testGenericblockExceptions: function(test) |