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

Delta Between Two Patch Sets: test/elemHideEmulation.js

Issue 29594607: Issue 5143 - Convert ElemHideEmulation to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Rebase. Review comments addressed. Created Jan. 25, 2018, 7:04 p.m.
Right Patch Set: Review comments addressed Created Jan. 30, 2018, 5:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « meson.build ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 test.equal(selectors.selectorAt(1), ".foo"); 80 test.equal(selectors.selectorAt(1), ".foo");
81 test.equal(selectors.filterKeyAt(1), "example.com##.foo"); 81 test.equal(selectors.filterKeyAt(1), "example.com##.foo");
82 })(elemHide.getSelectorsForDomain("example.com", 0)); 82 })(elemHide.getSelectorsForDomain("example.com", 0));
83 83
84 withNAD(0, filter3 => 84 withNAD(0, filter3 =>
85 { 85 {
86 elemHide.add(filter3); 86 elemHide.add(filter3);
87 87
88 withNAD( 88 withNAD(
89 0, selectors => 89 0, selectors =>
90 { 90 test.equal(selectors.selectorCount, 3))(
sergei 2018/01/30 16:00:48 It seems some changes like these are not related t
hub 2018/01/30 17:37:58 In a preview comment on this review you wanted to
sergei 2018/01/30 17:40:56 Ah, OK.
91 test.equal(selectors.selectorCount, 3);
92 test.equal(selectors.selectorAt(0), "#ads");
93 test.equal(selectors.selectorAt(1), ".message");
94 test.equal(selectors.selectorAt(2), ".foo");
95 })(
96 elemHide.getSelectorsForDomain("example.com", 0)); 91 elemHide.getSelectorsForDomain("example.com", 0));
97 92
98 withNAD( 93 withNAD(
99 0, selectors => 94 0, selectors =>
100 { 95 test.equal(selectors.selectorCount, 3))(
101 test.equal(selectors.selectorCount, 3);
102 test.equal(selectors.selectorAt(0), "#ads");
103 test.equal(selectors.selectorAt(1), ".message");
104 test.equal(selectors.selectorAt(2), ".foo");
105 })(
106 elemHide.getSelectorsForDomain("mail.example.com", 0)); 96 elemHide.getSelectorsForDomain("mail.example.com", 0));
107 97
108 withNAD(0, filter4 => 98 withNAD(0, filter4 =>
109 { 99 {
110 elemHide.add(filter4); 100 elemHide.add(filter4);
111 withNAD( 101 withNAD(
112 0, selectors => 102 0, selectors =>
113 { 103 test.equal(selectors.selectorCount, 3))(
114 test.equal(selectors.selectorCount, 3);
115 test.equal(selectors.selectorAt(0), "#ads");
116 test.equal(selectors.selectorAt(1), ".message");
117 test.equal(selectors.selectorAt(2), ".foo");
118 })(
119 elemHide.getSelectorsForDomain("example.com", 0)); 104 elemHide.getSelectorsForDomain("example.com", 0));
120 105
121 withNAD( 106 withNAD(
122 0, selectors => 107 0, selectors =>
123 { 108 test.equal(selectors.selectorCount, 2))(
124 test.equal(selectors.selectorCount, 2);
125 test.equal(selectors.selectorAt(0), "#ads");
126 test.equal(selectors.selectorAt(1), ".foo");
127 })(
128 elemHide.getSelectorsForDomain("mail.example.com", 0)); 109 elemHide.getSelectorsForDomain("mail.example.com", 0));
129 110
130 withNAD( 111 withNAD(
131 0, 112 0,
132 unconditionals => 113 unconditionals =>
133 { 114 test.equal(unconditionals.selectorCount, 1))(elemHide.getUncondition alSelectors());
134 test.equal(unconditionals.selectorCount, 1);
135 test.equal(unconditionals.selectorAt(0), "#ads");
136 })(elemHide.getUnconditionalSelectors());
137 115
138 elemHide.remove(filter4); 116 elemHide.remove(filter4);
139 })(Filter.fromText("mail.example.com#@#.message")); 117 })(Filter.fromText("mail.example.com#@#.message"));
140 118
141 withNAD( 119 withNAD(
142 0, selectors => 120 0, selectors =>
143 { 121 test.equal(selectors.selectorCount, 3))(
144 test.equal(selectors.selectorCount, 3); 122 elemHide.getSelectorsForDomain("example.com", 0));
145 test.equal(selectors.selectorAt(0), "#ads"); 123
146 test.equal(selectors.selectorAt(1), ".message"); 124 withNAD(
147 test.equal(selectors.selectorAt(2), ".foo"); 125 0, selectors =>
148 })(elemHide.getSelectorsForDomain("example.com", 0)); 126 test.equal(selectors.selectorCount, 3))(
149 127 elemHide.getSelectorsForDomain("mail.example.com", 0));
150 withNAD(
151 0, selectors =>
152 {
153 test.equal(selectors.selectorCount, 3);
154 test.equal(selectors.selectorAt(0), "#ads");
155 test.equal(selectors.selectorAt(1), ".message");
156 test.equal(selectors.selectorAt(2), ".foo");
157 })(elemHide.getSelectorsForDomain("mail.example.com", 0));
158 128
159 elemHide.remove(filter3); 129 elemHide.remove(filter3);
160 })(Filter.fromText("example.com##.message")); 130 })(Filter.fromText("example.com##.message"));
161 131
162 withNAD( 132 withNAD(
163 0, selectors => 133 0, selectors =>
164 test.equal(selectors.selectorCount, 2))( 134 test.equal(selectors.selectorCount, 2))(
165 elemHide.getSelectorsForDomain("example.com", 0)); 135 elemHide.getSelectorsForDomain("example.com", 0));
166 })(ElemHide.create()); 136 })(ElemHide.create());
167 137
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 218
249 test.done(); 219 test.done();
250 }; 220 };
251 221
252 exports.testElemHideEmulationFiltersContainer = function(test) 222 exports.testElemHideEmulationFiltersContainer = function(test)
253 { 223 {
254 withNAD([0, 1], (elemHide, elemHideEmulation) => 224 withNAD([0, 1], (elemHide, elemHideEmulation) =>
255 { 225 {
256 function compareRules(description, domain, expectedMatches) 226 function compareRules(description, domain, expectedMatches)
257 { 227 {
258 let rules = elemHideEmulation.getRulesForDomain(elemHide, domain); 228 withNAD(0, rules =>
259 let result = []; 229 {
260 for (let i = 0; i < rules.filterCount; i++) 230 let result = [];
261 { 231 for (let i = 0; i < rules.filterCount; i++)
262 let filter = rules.filterAt(i); 232 withNAD(0, filter => result.push(filter.text))(rules.filterAt(i));
263 result.push(filter.text); 233
264 filter.delete(); 234 expectedMatches = expectedMatches.map(filter => filter.text);
265 } 235 test.deepEqual(result.sort(), expectedMatches.sort(), description);
266 expectedMatches = expectedMatches.map(filter => filter.text); 236 })(elemHideEmulation.getRulesForDomain(elemHide, domain));
267 test.deepEqual(result.sort(), expectedMatches.sort(), description);
268
269 rules.delete();
270 } 237 }
271 238
272 withNAD([0, 1, 2], (domainFilter, subdomainFilter, otherDomainFilter) => 239 withNAD([0, 1, 2], (domainFilter, subdomainFilter, otherDomainFilter) =>
273 { 240 {
274 elemHideEmulation.add(domainFilter); 241 elemHideEmulation.add(domainFilter);
275 elemHideEmulation.add(subdomainFilter); 242 elemHideEmulation.add(subdomainFilter);
276 elemHideEmulation.add(otherDomainFilter); 243 elemHideEmulation.add(otherDomainFilter);
277 compareRules( 244 compareRules(
278 "Return all matching filters", 245 "Return all matching filters",
279 "www.example.com", 246 "www.example.com",
(...skipping 13 matching lines...) Expand all
293 "www.example.com", 260 "www.example.com",
294 [] 261 []
295 ); 262 );
296 })(Filter.fromText("example.com##filter1"), 263 })(Filter.fromText("example.com##filter1"),
297 Filter.fromText("www.example.com##filter2"), 264 Filter.fromText("www.example.com##filter2"),
298 Filter.fromText("other.example.com##filter3")); 265 Filter.fromText("other.example.com##filter3"));
299 })(ElemHide.create(), ElemHideEmulation.create()); 266 })(ElemHide.create(), ElemHideEmulation.create());
300 267
301 test.done(); 268 test.done();
302 }; 269 };
LEFTRIGHT
« meson.build ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld