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

Side by Side Diff: test/subscriptionClasses.js

Issue 30013628: Issue 7029 - Remove subscriptions property of Filter object (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 24, 2019, 1:30 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
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-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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 }; 134 };
135 135
136 exports.testFilterManagement = function(test) 136 exports.testFilterManagement = function(test)
137 { 137 {
138 let subscription = Subscription.fromURL("https://example.com/"); 138 let subscription = Subscription.fromURL("https://example.com/");
139 139
140 compareSubscriptionFilters(test, subscription, []); 140 compareSubscriptionFilters(test, subscription, []);
141 141
142 subscription.addFilter(f$("##.foo")); 142 subscription.addFilter(f$("##.foo"));
143 compareSubscriptionFilters(test, subscription, ["##.foo"]); 143 compareSubscriptionFilters(test, subscription, ["##.foo"]);
144 test.equal(subscription.searchFilter(f$("##.foo")), 0); 144 test.equal(subscription.findFilterIndex(f$("##.foo")), 0);
145 145
146 subscription.addFilter(f$("##.bar")); 146 subscription.addFilter(f$("##.bar"));
147 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar"]); 147 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar"]);
148 test.equal(subscription.searchFilter(f$("##.bar")), 1); 148 test.equal(subscription.findFilterIndex(f$("##.bar")), 1);
149 149
150 // Repeat filter. 150 // Repeat filter.
151 subscription.addFilter(f$("##.bar")); 151 subscription.addFilter(f$("##.bar"));
152 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar", 152 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar",
153 "##.bar"]); 153 "##.bar"]);
154 154
155 // The first occurrence is found. 155 // The first occurrence is found.
156 test.equal(subscription.searchFilter(f$("##.bar")), 1); 156 test.equal(subscription.findFilterIndex(f$("##.bar")), 1);
157 157
158 subscription.deleteFilterAt(0); 158 subscription.deleteFilterAt(0);
159 compareSubscriptionFilters(test, subscription, ["##.bar", "##.bar"]); 159 compareSubscriptionFilters(test, subscription, ["##.bar", "##.bar"]);
160 test.equal(subscription.searchFilter(f$("##.bar")), 0); 160 test.equal(subscription.findFilterIndex(f$("##.bar")), 0);
161 161
162 subscription.insertFilterAt(f$("##.foo"), 0); 162 subscription.insertFilterAt(f$("##.foo"), 0);
163 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar", 163 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar",
164 "##.bar"]); 164 "##.bar"]);
165 test.equal(subscription.searchFilter(f$("##.bar")), 1); 165 test.equal(subscription.findFilterIndex(f$("##.bar")), 1);
166 166
167 subscription.deleteFilterAt(1); 167 subscription.deleteFilterAt(1);
168 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar"]); 168 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar"]);
169 test.equal(subscription.searchFilter(f$("##.bar")), 1); 169 test.equal(subscription.findFilterIndex(f$("##.bar")), 1);
170 170
171 subscription.deleteFilterAt(1); 171 subscription.deleteFilterAt(1);
172 compareSubscriptionFilters(test, subscription, ["##.foo"]); 172 compareSubscriptionFilters(test, subscription, ["##.foo"]);
173 test.equal(subscription.searchFilter(f$("##.bar")), -1); 173 test.equal(subscription.findFilterIndex(f$("##.bar")), -1);
174 174
175 subscription.addFilter(f$("##.bar")); 175 subscription.addFilter(f$("##.bar"));
176 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar"]); 176 compareSubscriptionFilters(test, subscription, ["##.foo", "##.bar"]);
177 test.equal(subscription.searchFilter(f$("##.bar")), 1); 177 test.equal(subscription.findFilterIndex(f$("##.bar")), 1);
178 178
179 subscription.clearFilters(); 179 subscription.clearFilters();
180 compareSubscriptionFilters(test, subscription, []); 180 compareSubscriptionFilters(test, subscription, []);
181 test.equal(subscription.searchFilter(f$("##.foo")), -1); 181 test.equal(subscription.findFilterIndex(f$("##.foo")), -1);
182 test.equal(subscription.searchFilter(f$("##.bar")), -1); 182 test.equal(subscription.findFilterIndex(f$("##.bar")), -1);
183 183
184 subscription.addFilter(f$("##.bar")); 184 subscription.addFilter(f$("##.bar"));
185 compareSubscriptionFilters(test, subscription, ["##.bar"]); 185 compareSubscriptionFilters(test, subscription, ["##.bar"]);
186 186
187 subscription.addFilter(f$("##.foo")); 187 subscription.addFilter(f$("##.foo"));
188 compareSubscriptionFilters(test, subscription, ["##.bar", "##.foo"]); 188 compareSubscriptionFilters(test, subscription, ["##.bar", "##.foo"]);
189 test.equal(subscription.searchFilter(f$("##.bar")), 0); 189 test.equal(subscription.findFilterIndex(f$("##.bar")), 0);
190 test.equal(subscription.searchFilter(f$("##.foo")), 1); 190 test.equal(subscription.findFilterIndex(f$("##.foo")), 1);
191 191
192 // Insert outside of bounds. 192 // Insert outside of bounds.
193 subscription.insertFilterAt(f$("##.lambda"), 1000); 193 subscription.insertFilterAt(f$("##.lambda"), 1000);
194 compareSubscriptionFilters(test, subscription, ["##.bar", "##.foo", 194 compareSubscriptionFilters(test, subscription, ["##.bar", "##.foo",
195 "##.lambda"]); 195 "##.lambda"]);
196 test.equal(subscription.searchFilter(f$("##.lambda")), 2); 196 test.equal(subscription.findFilterIndex(f$("##.lambda")), 2);
197 197
198 // Delete outside of bounds. 198 // Delete outside of bounds.
199 subscription.deleteFilterAt(1000); 199 subscription.deleteFilterAt(1000);
200 compareSubscriptionFilters(test, subscription, ["##.bar", "##.foo", 200 compareSubscriptionFilters(test, subscription, ["##.bar", "##.foo",
201 "##.lambda"]); 201 "##.lambda"]);
202 test.equal(subscription.searchFilter(f$("##.lambda")), 2); 202 test.equal(subscription.findFilterIndex(f$("##.lambda")), 2);
203 203
204 // Insert outside of bounds (negative). 204 // Insert outside of bounds (negative).
205 subscription.insertFilterAt(f$("##.lambda"), -1000); 205 subscription.insertFilterAt(f$("##.lambda"), -1000);
206 compareSubscriptionFilters(test, subscription, ["##.lambda", "##.bar", 206 compareSubscriptionFilters(test, subscription, ["##.lambda", "##.bar",
207 "##.foo", "##.lambda"]); 207 "##.foo", "##.lambda"]);
208 test.equal(subscription.searchFilter(f$("##.lambda")), 0); 208 test.equal(subscription.findFilterIndex(f$("##.lambda")), 0);
209 209
210 // Delete outside of bounds (negative). 210 // Delete outside of bounds (negative).
211 subscription.deleteFilterAt(-1000); 211 subscription.deleteFilterAt(-1000);
212 compareSubscriptionFilters(test, subscription, ["##.lambda", "##.bar", 212 compareSubscriptionFilters(test, subscription, ["##.lambda", "##.bar",
213 "##.foo", "##.lambda"]); 213 "##.foo", "##.lambda"]);
214 test.equal(subscription.searchFilter(f$("##.lambda")), 0); 214 test.equal(subscription.findFilterIndex(f$("##.lambda")), 0);
215 215
216 test.done(); 216 test.done();
217 }; 217 };
OLDNEW
« test/filterStorage_readwrite.js ('K') | « test/filterStorage_readwrite.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld