OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 let testRunner = null; | 3 let testRunner = null; |
4 let requestHandlers = null; | 4 let requestHandlers = null; |
5 let randomResult = 0.5; | 5 let randomResult = 0.5; |
6 | 6 |
7 module("Synchronizer", { | 7 module("Synchronizer", { |
8 setup: function() | 8 setup: function() |
9 { | 9 { |
10 testRunner = this; | 10 testRunner = this; |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 resetSubscription(subscription); | 352 resetSubscription(subscription); |
353 testRunner.runScheduledTasks(15); | 353 testRunner.runScheduledTasks(15); |
354 equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "
Redirect followed"); | 354 equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "
Redirect followed"); |
355 deepEqual(requests, [0.1, 8.1], "Resulting requests"); | 355 deepEqual(requests, [0.1, 8.1], "Resulting requests"); |
356 | 356 |
357 testRunner.registerHandler("/redirected", function(metadata) | 357 testRunner.registerHandler("/redirected", function(metadata) |
358 { | 358 { |
359 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Redirect: http://example.com/subs
cription\nbar"]; | 359 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Redirect: http://example.com/subs
cription\nbar"]; |
360 }) | 360 }) |
361 | 361 |
362 let subscription = Subscription.fromURL("http://example.com/subscription"); | 362 subscription = Subscription.fromURL("http://example.com/subscription"); |
363 resetSubscription(subscription); | 363 resetSubscription(subscription); |
364 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); | 364 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); |
365 FilterStorage.addSubscription(subscription); | 365 FilterStorage.addSubscription(subscription); |
366 | 366 |
367 testRunner.runScheduledTasks(2); | 367 testRunner.runScheduledTasks(2); |
368 equal(FilterStorage.subscriptions[0], subscription, "Redirect not followed o
n redirect loop"); | 368 equal(FilterStorage.subscriptions[0], subscription, "Redirect not followed o
n redirect loop"); |
369 equal(subscription.downloadStatus, "synchronize_connection_error", "Download
status after redirect loop"); | 369 equal(subscription.downloadStatus, "synchronize_connection_error", "Download
status after redirect loop"); |
370 }); | 370 }); |
371 | 371 |
372 test("Fallback", function() | 372 test("Fallback", function() |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 testRunner.runScheduledTasks(24); | 511 testRunner.runScheduledTasks(24); |
512 | 512 |
513 equal(subscription.downloadStatus, "synchronize_connection_error", "download
Status after download error"); | 513 equal(subscription.downloadStatus, "synchronize_connection_error", "download
Status after download error"); |
514 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + 26.1 * MILLI
S_IN_HOUR, "lastDownload after download error"); | 514 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + 26.1 * MILLI
S_IN_HOUR, "lastDownload after download error"); |
515 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + 0.1 * MILLIS_
IN_HOUR, "lastSuccess after download error"); | 515 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + 0.1 * MILLIS_
IN_HOUR, "lastSuccess after download error"); |
516 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + 27.1 * MILLIS_I
N_HOUR, "lastCheck after download error"); | 516 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + 27.1 * MILLIS_I
N_HOUR, "lastCheck after download error"); |
517 equal(subscription.errors, 2, "errors after download error"); | 517 equal(subscription.errors, 2, "errors after download error"); |
518 }); | 518 }); |
519 })(); | 519 })(); |
OLD | NEW |