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

Side by Side Diff: test/synchronizer.js

Issue 29873570: Issue 6923 - Only parse metadata from special comments at the top of the file (Closed)
Patch Set: Change end-of-metadata semantics Created Sept. 4, 2018, 8:14 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
« lib/synchronizer.js ('K') | « lib/synchronizer.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-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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 testId += " skipping " + currentTest.skip + " hours after " + currentTest.sk ipAfter + " hours"; 252 testId += " skipping " + currentTest.skip + " hours after " + currentTest.sk ipAfter + " hours";
253 exports.testExpirationTime[testId] = function(test) 253 exports.testExpirationTime[testId] = function(test)
254 { 254 {
255 let subscription = Subscription.fromURL("http://example.com/subscription"); 255 let subscription = Subscription.fromURL("http://example.com/subscription");
256 FilterStorage.addSubscription(subscription); 256 FilterStorage.addSubscription(subscription);
257 257
258 let requests = []; 258 let requests = [];
259 this.registerHandler("/subscription", metadata => 259 this.registerHandler("/subscription", metadata =>
260 { 260 {
261 requests.push(this.getTimeOffset()); 261 requests.push(this.getTimeOffset());
262 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Expires: " + currentTest.expirati on + "\nbar"]; 262 return [Cr.NS_OK, 200, "[Adblock]\n!Expires: " + currentTest.expiration + "\nbar"];
263 }); 263 });
264 264
265 this.randomResult = currentTest.randomResult; 265 this.randomResult = currentTest.randomResult;
266 266
267 let maxHours = Math.round(Math.max.apply(null, currentTest.requests)) + 1; 267 let maxHours = Math.round(Math.max.apply(null, currentTest.requests)) + 1;
268 this.runScheduledTasks(maxHours, currentTest.skipAfter, currentTest.skip).th en(() => 268 this.runScheduledTasks(maxHours, currentTest.skipAfter, currentTest.skip).th en(() =>
269 { 269 {
270 test.deepEqual(requests, currentTest.requests, "Requests"); 270 test.deepEqual(requests, currentTest.requests, "Requests");
271 }).catch(unexpectedError.bind(test)).then(() => test.done()); 271 }).catch(unexpectedError.bind(test)).then(() => test.done());
272 }; 272 };
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 }; 312 };
313 } 313 }
314 314
315 exports.testRedirects = function(test) 315 exports.testRedirects = function(test)
316 { 316 {
317 let subscription = Subscription.fromURL("http://example.com/subscription"); 317 let subscription = Subscription.fromURL("http://example.com/subscription");
318 FilterStorage.addSubscription(subscription); 318 FilterStorage.addSubscription(subscription);
319 319
320 this.registerHandler("/subscription", metadata => 320 this.registerHandler("/subscription", metadata =>
321 { 321 {
322 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Redirect: http://example.com/redire cted\nbar"]; 322 return [Cr.NS_OK, 200, "[Adblock]\n!Redirect: http://example.com/redirected\ nbar"];
323 }); 323 });
324 324
325 let requests; 325 let requests;
326 326
327 this.runScheduledTasks(30).then(() => 327 this.runScheduledTasks(30).then(() =>
328 { 328 {
329 test.equal(FilterStorage.subscriptions[0], subscription, "Invalid redirect i gnored"); 329 test.equal(FilterStorage.subscriptions[0], subscription, "Invalid redirect i gnored");
330 test.equal(subscription.downloadStatus, "synchronize_connection_error", "Con nection error recorded"); 330 test.equal(subscription.downloadStatus, "synchronize_connection_error", "Con nection error recorded");
331 test.equal(subscription.errors, 2, "Number of download errors"); 331 test.equal(subscription.errors, 2, "Number of download errors");
332 332
333 requests = []; 333 requests = [];
334 334
335 this.registerHandler("/redirected", metadata => 335 this.registerHandler("/redirected", metadata =>
336 { 336 {
337 requests.push(this.getTimeOffset()); 337 requests.push(this.getTimeOffset());
338 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n! Expires: 8 hours\nbar"]; 338 return [Cr.NS_OK, 200, "[Adblock]\n! Expires: 8 hours\nbar"];
339 }); 339 });
340 340
341 resetSubscription(subscription); 341 resetSubscription(subscription);
342 return this.runScheduledTasks(15); 342 return this.runScheduledTasks(15);
343 }).then(() => 343 }).then(() =>
344 { 344 {
345 test.equal(FilterStorage.subscriptions[0].url, "http://example.com/redirecte d", "Redirect followed"); 345 test.equal(FilterStorage.subscriptions[0].url, "http://example.com/redirecte d", "Redirect followed");
346 test.deepEqual(requests, [0 + initialDelay, 8 + initialDelay], "Resulting re quests"); 346 test.deepEqual(requests, [0 + initialDelay, 8 + initialDelay], "Resulting re quests");
347 347
348 this.registerHandler("/redirected", metadata => 348 this.registerHandler("/redirected", metadata =>
349 { 349 {
350 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Redirect: http://example.com/subs cription\nbar"]; 350 return [Cr.NS_OK, 200, "[Adblock]\n!Redirect: http://example.com/subscript ion\nbar"];
351 }); 351 });
352 352
353 subscription = Subscription.fromURL("http://example.com/subscription"); 353 subscription = Subscription.fromURL("http://example.com/subscription");
354 resetSubscription(subscription); 354 resetSubscription(subscription);
355 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); 355 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]);
356 FilterStorage.addSubscription(subscription); 356 FilterStorage.addSubscription(subscription);
357 357
358 return this.runScheduledTasks(2); 358 return this.runScheduledTasks(2);
359 }).then(() => 359 }).then(() =>
360 { 360 {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 return this.runScheduledTasks(24); 503 return this.runScheduledTasks(24);
504 }).then(() => 504 }).then(() =>
505 { 505 {
506 test.equal(subscription.downloadStatus, "synchronize_connection_error", "dow nloadStatus after download error"); 506 test.equal(subscription.downloadStatus, "synchronize_connection_error", "dow nloadStatus after download error");
507 test.equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + (26 + i nitialDelay) * MILLIS_IN_HOUR, "lastDownload after download error"); 507 test.equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + (26 + i nitialDelay) * MILLIS_IN_HOUR, "lastDownload after download error");
508 test.equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialD elay * MILLIS_IN_HOUR, "lastSuccess after download error"); 508 test.equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialD elay * MILLIS_IN_HOUR, "lastSuccess after download error");
509 test.equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (27 + init ialDelay) * MILLIS_IN_HOUR, "lastCheck after download error"); 509 test.equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (27 + init ialDelay) * MILLIS_IN_HOUR, "lastCheck after download error");
510 test.equal(subscription.errors, 2, "errors after download error"); 510 test.equal(subscription.errors, 2, "errors after download error");
511 }).catch(unexpectedError.bind(test)).then(() => test.done()); 511 }).catch(unexpectedError.bind(test)).then(() => test.done());
512 }; 512 };
OLDNEW
« lib/synchronizer.js ('K') | « lib/synchronizer.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld