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

Delta Between Two Patch Sets: test/synchronizer.js

Issue 29934588: Issue 7094 - Encapsulate management of subscription filters (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Nov. 2, 2018, 10:34 p.m.
Right Patch Set: Remove hasFilter and related code Created Nov. 18, 2018, 10:21 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
« lib/subscriptionClasses.js ('K') | « test/subscriptionClasses.js ('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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return [Cr.NS_OK, 200, currentTest.header + "\n!Expires: 8 hours\nfoo\n!ba r\n\n@@bas\n#bam"]; 134 return [Cr.NS_OK, 200, currentTest.header + "\n!Expires: 8 hours\nfoo\n!ba r\n\n@@bas\n#bam"];
135 }); 135 });
136 136
137 this.runScheduledTasks(2).then(() => 137 this.runScheduledTasks(2).then(() =>
138 { 138 {
139 test.equal(subscription.downloadStatus, currentTest.downloadStatus, "Downl oad status"); 139 test.equal(subscription.downloadStatus, currentTest.downloadStatus, "Downl oad status");
140 test.equal(subscription.requiredVersion, currentTest.requiredVersion, "Req uired version"); 140 test.equal(subscription.requiredVersion, currentTest.requiredVersion, "Req uired version");
141 141
142 if (currentTest.downloadStatus == "synchronize_ok") 142 if (currentTest.downloadStatus == "synchronize_ok")
143 { 143 {
144 test.deepEqual(subscription.filters, ["foo", "!bar", "@@bas", "#bam"], " Resulting subscription filters"); 144 test.deepEqual([...subscription.filterText()], ["foo", "!bar", "@@bas", "#bam"], "Resulting subscription filters");
145 } 145 }
146 else 146 else
147 { 147 {
148 test.deepEqual(subscription.filters, [ 148 test.deepEqual([...subscription.filterText()], [
149 ], "Resulting subscription filters"); 149 ], "Resulting subscription filters");
150 } 150 }
151 }).catch(unexpectedError.bind(test)).then(() => test.done()); 151 }).catch(unexpectedError.bind(test)).then(() => test.done());
152 }; 152 };
153 } 153 }
154 154
155 exports.testsDisabledUpdates = function(test) 155 exports.testsDisabledUpdates = function(test)
156 { 156 {
157 Prefs.subscriptions_autoupdate = false; 157 Prefs.subscriptions_autoupdate = false;
158 158
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 filterStorage.addSubscription(subscription); 293 filterStorage.addSubscription(subscription);
294 294
295 this.registerHandler("/subscription", metadata => 295 this.registerHandler("/subscription", metadata =>
296 { 296 {
297 return [Cr.NS_OK, 200, "[Adblock]\n" + comment + "\nfoo\nbar"]; 297 return [Cr.NS_OK, 200, "[Adblock]\n" + comment + "\nfoo\nbar"];
298 }); 298 });
299 299
300 this.runScheduledTasks(2).then(() => 300 this.runScheduledTasks(2).then(() =>
301 { 301 {
302 check(test, subscription); 302 check(test, subscription);
303 test.deepEqual(subscription.filters, ["foo", "bar"], "Special comment not added to filters"); 303 test.deepEqual([...subscription.filterText()], ["foo", "bar"], "Special co mment not added to filters");
304 }).catch(unexpectedError.bind(test)).then(() => test.done()); 304 }).catch(unexpectedError.bind(test)).then(() => test.done());
305 }; 305 };
306 } 306 }
307 307
308 exports.testRedirects = function(test) 308 exports.testRedirects = function(test)
309 { 309 {
310 let subscription = Subscription.fromURL("http://example.com/subscription"); 310 let subscription = Subscription.fromURL("http://example.com/subscription");
311 filterStorage.addSubscription(subscription); 311 filterStorage.addSubscription(subscription);
312 312
313 this.registerHandler("/subscription", metadata => 313 this.registerHandler("/subscription", metadata =>
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 return this.runScheduledTasks(24); 496 return this.runScheduledTasks(24);
497 }).then(() => 497 }).then(() =>
498 { 498 {
499 test.equal(subscription.downloadStatus, "synchronize_connection_error", "dow nloadStatus after download error"); 499 test.equal(subscription.downloadStatus, "synchronize_connection_error", "dow nloadStatus after download error");
500 test.equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + (26 + i nitialDelay) * MILLIS_IN_HOUR, "lastDownload after download error"); 500 test.equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + (26 + i nitialDelay) * MILLIS_IN_HOUR, "lastDownload after download error");
501 test.equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialD elay * MILLIS_IN_HOUR, "lastSuccess after download error"); 501 test.equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialD elay * MILLIS_IN_HOUR, "lastSuccess after download error");
502 test.equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (27 + init ialDelay) * MILLIS_IN_HOUR, "lastCheck after download error"); 502 test.equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (27 + init ialDelay) * MILLIS_IN_HOUR, "lastCheck after download error");
503 test.equal(subscription.errors, 2, "errors after download error"); 503 test.equal(subscription.errors, 2, "errors after download error");
504 }).catch(unexpectedError.bind(test)).then(() => test.done()); 504 }).catch(unexpectedError.bind(test)).then(() => test.done());
505 }; 505 };
506
507 exports.testSpecialCommentOrdering = function(test)
508 {
509 let subscription = Subscription.fromURL("http://example.com/subscription");
510 filterStorage.addSubscription(subscription);
511
512 this.registerHandler("/subscription", metadata =>
513 {
514 return [Cr.NS_OK, 200, "[Adblock]\n! Special Comment: x\n!foo\n! Title: foob ar\nfoo\nbar"];
515 });
516
517 this.runScheduledTasks(1).then(() =>
518 {
519 test.equal(subscription.title, "http://example.com/subscription", "make sure title was not found");
520 }).catch(unexpectedError.bind(test)).then(() => test.done());
521 };
522
523 exports.testUnknownSpecialComments = function(test)
524 {
525 let subscription = Subscription.fromURL("http://example.com/subscription");
526 filterStorage.addSubscription(subscription);
527
528 this.registerHandler("/subscription", metadata =>
529 {
530 // To test allowing unknown special comments like `! :`, `!!@#$%^&*() : `, a nd `! Some Unknown Comment : `
531 return [Cr.NS_OK, 200, "[Adblock]\n! :\n! !@#$%^&*() :\n! Some Unknown Comme nt :\n! Title: foobar\nfoo\nbar"];
532 });
533
534 this.runScheduledTasks(1).then(() =>
535 {
536 test.equal(subscription.title, "foobar", "make sure title was found");
537 }).catch(unexpectedError.bind(test)).then(() => test.done());
538 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld