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

Side by Side Diff: test/abp2blocklist.js

Issue 29349790: Issue 4326 - || should match subdomains too (Closed)
Patch Set: Created Aug. 12, 2016, 2:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/abp2blocklist.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 test.done(); 66 test.done();
67 }, 67 },
68 68
69 testRequestFilters: function(test) 69 testRequestFilters: function(test)
70 { 70 {
71 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [ 71 testRules(test, ["/foo", "||test.com", "http://example.com/foo"], [
72 {trigger: {"url-filter": "^https?://.*/foo", 72 {trigger: {"url-filter": "^https?://.*/foo",
73 "resource-type": ["image", "style-sheet", "script", "font", 73 "resource-type": ["image", "style-sheet", "script", "font",
74 "media", "raw", "document"]}, 74 "media", "raw", "document"]},
75 action: {type: "block"}}, 75 action: {type: "block"}},
76 {trigger: {"url-filter": "^https?://test\\.com", 76 {trigger: {"url-filter": "^https?://([^/]+\\.)?test\\.com",
77 "url-filter-is-case-sensitive": true, 77 "url-filter-is-case-sensitive": true,
78 "resource-type": ["image", "style-sheet", "script", "font", 78 "resource-type": ["image", "style-sheet", "script", "font",
79 "media", "raw", "document"]}, 79 "media", "raw", "document"]},
80 action: {type: "block"}}, 80 action: {type: "block"}},
81 {trigger: {"url-filter": "http://example\\.com/foo", 81 {trigger: {"url-filter": "http://example\\.com/foo",
82 "resource-type": ["image", "style-sheet", "script", "font", 82 "resource-type": ["image", "style-sheet", "script", "font",
83 "media", "raw", "document"]}, 83 "media", "raw", "document"]},
84 action: {type: "block"}} 84 action: {type: "block"}}
85 ]); 85 ]);
86 86
87 testRules(test, ["||example.com"], [
88 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
89 "url-filter-is-case-sensitive": true,
90 "resource-type": ["image", "style-sheet", "script", "font",
91 "media", "raw", "document"]},
92
93 action: {type: "block"}}
94 ]);
95
96
87 test.done(); 97 test.done();
88 }, 98 },
89 99
90 testRequestFilterExceptions: function(test) 100 testRequestFilterExceptions: function(test)
91 { 101 {
92 testRules(test, ["@@example.com"], [ 102 testRules(test, ["@@example.com"], [
93 {trigger: {"url-filter": "^https?://.*example\\.com", 103 {trigger: {"url-filter": "^https?://.*example\\.com",
94 "resource-type": ["image", "style-sheet", "script", "font", 104 "resource-type": ["image", "style-sheet", "script", "font",
95 "media", "raw", "document"]}, 105 "media", "raw", "document"]},
96 action: {type: "ignore-previous-rules"}} 106 action: {type: "ignore-previous-rules"}}
97 ]); 107 ]);
98 108
109 testRules(test, ["@@||example.com"], [
110 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
111 "url-filter-is-case-sensitive": true,
112 "resource-type": ["image", "style-sheet", "script", "font",
113 "media", "raw", "document"]},
114 action: {type: "ignore-previous-rules"}}
115 ]);
116
99 test.done(); 117 test.done();
100 }, 118 },
101 119
102 testElementIDattributeFormat: function(test) 120 testElementIDattributeFormat: function(test)
103 { 121 {
104 testRules(test, 122 testRules(test,
105 ["###example", "test.com###EXAMPLE"], 123 ["###example", "test.com###EXAMPLE"],
106 ["[id=example]", "[id=EXAMPLE]"], 124 ["[id=example]", "[id=EXAMPLE]"],
107 rules => rules.map(rule => rule.action.selector)); 125 rules => rules.map(rule => rule.action.selector));
108 126
109 test.done(); 127 test.done();
110 }, 128 },
111 129
112 testDomainWhitelisting: function(test) 130 testDomainWhitelisting: function(test)
113 { 131 {
114 testRules(test, ["@@||example.com^$document"], [ 132 testRules(test, ["@@||example.com^$document"], [
115 {trigger: {"url-filter": ".*", 133 {trigger: {"url-filter": ".*",
116 "if-domain": ["example.com", "www.example.com"]}, 134 "if-domain": ["example.com", "www.example.com"]},
117 action: {type: "ignore-previous-rules"}} 135 action: {type: "ignore-previous-rules"}}
118 ]); 136 ]);
119 testRules(test, ["@@||example.com^$document,image"], [ 137 testRules(test, ["@@||example.com^$document,image"], [
120 {trigger: {"url-filter": ".*", 138 {trigger: {"url-filter": ".*",
121 "if-domain": ["example.com", "www.example.com"]}, 139 "if-domain": ["example.com", "www.example.com"]},
122 action: {type: "ignore-previous-rules"}}, 140 action: {type: "ignore-previous-rules"}},
123 {trigger: {"url-filter": "^https?://example\\.com", 141 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com",
124 "url-filter-is-case-sensitive": true, 142 "url-filter-is-case-sensitive": true,
125 "resource-type": ["image"]}, 143 "resource-type": ["image"]},
126 action: {type: "ignore-previous-rules"}} 144 action: {type: "ignore-previous-rules"}}
127 ]); 145 ]);
128 testRules(test, ["@@||example.com/path^$font,document"], [ 146 testRules(test, ["@@||example.com/path^$font,document"], [
129 {trigger: {"url-filter": "^https?://example\\.com/path", 147 {trigger: {"url-filter": "^https?://([^/]+\\.)?example\\.com/path",
130 "resource-type": ["font"]}, 148 "resource-type": ["font"]},
131 action: {type: "ignore-previous-rules"}} 149 action: {type: "ignore-previous-rules"}}
132 ]); 150 ]);
133 151
134 test.done(); 152 test.done();
135 }, 153 },
136 154
137 testRuleOrdering: function(test) 155 testRuleOrdering: function(test)
138 { 156 {
139 testRules( 157 testRules(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 testUnicode: function(test) 225 testUnicode: function(test)
208 { 226 {
209 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"], 227 testRules(test, ["$domain=🐈.cat"], ["xn--zn8h.cat", "www.xn--zn8h.cat"],
210 rules => rules[0]["trigger"]["if-domain"]); 228 rules => rules[0]["trigger"]["if-domain"]);
211 testRules(test, ["🐈$domain=🐈.cat"], []); 229 testRules(test, ["🐈$domain=🐈.cat"], []);
212 testRules(test, ["###🐈"], []); 230 testRules(test, ["###🐈"], []);
213 231
214 test.done(); 232 test.done();
215 } 233 }
216 }; 234 };
OLDNEW
« 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