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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 subscription.lastCheck = subscription.lastDownload = | 52 subscription.lastCheck = subscription.lastDownload = |
53 subscription.version = subscription.lastSuccess = | 53 subscription.version = subscription.lastSuccess = |
54 subscription.expires = subscription.softExpiration = 0; | 54 subscription.expires = subscription.softExpiration = 0; |
55 subscription.title = ""; | 55 subscription.title = ""; |
56 subscription.homepage = null; | 56 subscription.homepage = null; |
57 subscription.errors = 0; | 57 subscription.errors = 0; |
58 subscription.downloadStatus = null; | 58 subscription.downloadStatus = null; |
59 subscription.requiredVersion = null; | 59 subscription.requiredVersion = null; |
60 } | 60 } |
61 | 61 |
| 62 let initialDelay = 1 / 60; |
| 63 |
62 test("Downloads of one subscription", function() | 64 test("Downloads of one subscription", function() |
63 { | 65 { |
64 let subscription = Subscription.fromURL("http://example.com/subscription"); | 66 let subscription = Subscription.fromURL("http://example.com/subscription"); |
65 FilterStorage.addSubscription(subscription); | 67 FilterStorage.addSubscription(subscription); |
66 | 68 |
67 let requests = []; | 69 let requests = []; |
68 testRunner.registerHandler("/subscription", function(metadata) | 70 testRunner.registerHandler("/subscription", function(metadata) |
69 { | 71 { |
70 requests.push([testRunner.getTimeOffset(), metadata.method, metadata.path]
); | 72 requests.push([testRunner.getTimeOffset(), metadata.method, metadata.path]
); |
71 return [Cr.NS_OK, 200, "[Adblock]\n! ExPiREs: 1day\nfoo\nbar"]; | 73 return [Cr.NS_OK, 200, "[Adblock]\n! ExPiREs: 1day\nfoo\nbar"]; |
72 }); | 74 }); |
73 | 75 |
74 testRunner.runScheduledTasks(50); | 76 testRunner.runScheduledTasks(50); |
75 deepEqual(requests, [ | 77 deepEqual(requests, [ |
76 [0.1, "GET", "/subscription"], | 78 [0 + initialDelay, "GET", "/subscription"], |
77 [24.1, "GET", "/subscription"], | 79 [24 + initialDelay, "GET", "/subscription"], |
78 [48.1, "GET", "/subscription"], | 80 [48 + initialDelay, "GET", "/subscription"], |
79 ], "Requests after 50 hours"); | 81 ], "Requests after 50 hours"); |
80 }); | 82 }); |
81 | 83 |
82 test("Downloads of two subscriptions", function() | 84 test("Downloads of two subscriptions", function() |
83 { | 85 { |
84 let subscription1 = Subscription.fromURL("http://example.com/subscription1")
; | 86 let subscription1 = Subscription.fromURL("http://example.com/subscription1")
; |
85 FilterStorage.addSubscription(subscription1); | 87 FilterStorage.addSubscription(subscription1); |
86 | 88 |
87 let subscription2 = Subscription.fromURL("http://example.com/subscription2")
; | 89 let subscription2 = Subscription.fromURL("http://example.com/subscription2")
; |
88 subscription2.expires = | 90 subscription2.expires = |
89 subscription2.softExpiration = | 91 subscription2.softExpiration = |
90 (testRunner.currentTime + 2 * MILLIS_IN_HOUR) / MILLIS_IN_SECOND; | 92 (testRunner.currentTime + 2 * MILLIS_IN_HOUR) / MILLIS_IN_SECOND; |
91 FilterStorage.addSubscription(subscription2); | 93 FilterStorage.addSubscription(subscription2); |
92 | 94 |
93 let requests = []; | 95 let requests = []; |
94 function handler(metadata) | 96 function handler(metadata) |
95 { | 97 { |
96 requests.push([testRunner.getTimeOffset(), metadata.method, metadata.path]
); | 98 requests.push([testRunner.getTimeOffset(), metadata.method, metadata.path]
); |
97 return [Cr.NS_OK, 200, "[Adblock]\n! ExPiREs: 1day\nfoo\nbar"]; | 99 return [Cr.NS_OK, 200, "[Adblock]\n! ExPiREs: 1day\nfoo\nbar"]; |
98 } | 100 } |
99 | 101 |
100 testRunner.registerHandler("/subscription1", handler); | 102 testRunner.registerHandler("/subscription1", handler); |
101 testRunner.registerHandler("/subscription2", handler); | 103 testRunner.registerHandler("/subscription2", handler); |
102 | 104 |
103 testRunner.runScheduledTasks(55); | 105 testRunner.runScheduledTasks(55); |
104 deepEqual(requests, [ | 106 deepEqual(requests, [ |
105 [0.1, "GET", "/subscription1"], | 107 [0 + initialDelay, "GET", "/subscription1"], |
106 [2.1, "GET", "/subscription2"], | 108 [2 + initialDelay, "GET", "/subscription2"], |
107 [24.1, "GET", "/subscription1"], | 109 [24 + initialDelay, "GET", "/subscription1"], |
108 [26.1, "GET", "/subscription2"], | 110 [26 + initialDelay, "GET", "/subscription2"], |
109 [48.1, "GET", "/subscription1"], | 111 [48 + initialDelay, "GET", "/subscription1"], |
110 [50.1, "GET", "/subscription2"], | 112 [50 + initialDelay, "GET", "/subscription2"], |
111 ], "Requests after 55 hours"); | 113 ], "Requests after 55 hours"); |
112 }); | 114 }); |
113 | 115 |
114 test("Download result, various subscription headers", function() | 116 test("Download result, various subscription headers", function() |
115 { | 117 { |
116 let test; | 118 let test; |
117 let subscription = Subscription.fromURL("http://example.com/subscription"); | 119 let subscription = Subscription.fromURL("http://example.com/subscription"); |
118 FilterStorage.addSubscription(subscription); | 120 FilterStorage.addSubscription(subscription); |
119 | 121 |
120 testRunner.registerHandler("/subscription", function(metadata) | 122 testRunner.registerHandler("/subscription", function(metadata) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 testRunner.registerHandler("/subscription", function(metadata) | 185 testRunner.registerHandler("/subscription", function(metadata) |
184 { | 186 { |
185 requests.push(testRunner.getTimeOffset()); | 187 requests.push(testRunner.getTimeOffset()); |
186 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Expires: " + test.expiration + "\
nbar"]; | 188 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Expires: " + test.expiration + "\
nbar"]; |
187 }); | 189 }); |
188 | 190 |
189 let tests = [ | 191 let tests = [ |
190 { | 192 { |
191 expiration: "default", | 193 expiration: "default", |
192 randomResult: 0.5, | 194 randomResult: 0.5, |
193 requests: [0.1, 5 * 24 + 0.1] | 195 requests: [0 + initialDelay, 5 * 24 + initialDelay] |
194 }, | 196 }, |
195 { | 197 { |
196 expiration: "1 hours", // Minimal expiration interval | 198 expiration: "1 hours", // Minimal expiration interval |
197 randomResult: 0.5, | 199 randomResult: 0.5, |
198 requests: [0.1, 1.1, 2.1, 3.1] | 200 requests: [0 + initialDelay, 1 + initialDelay, 2 + initialDelay, 3 + ini
tialDelay] |
199 }, | 201 }, |
200 { | 202 { |
201 expiration: "26 hours", | 203 expiration: "26 hours", |
202 randomResult: 0.5, | 204 randomResult: 0.5, |
203 requests: [0.1, 26.1] | 205 requests: [0 + initialDelay, 26 + initialDelay] |
204 }, | 206 }, |
205 { | 207 { |
206 expiration: "2 days", | 208 expiration: "2 days", |
207 randomResult: 0.5, | 209 randomResult: 0.5, |
208 requests: [0.1, 48.1] | 210 requests: [0 + initialDelay, 48 + initialDelay] |
209 }, | 211 }, |
210 { | 212 { |
211 expiration: "20 days", // Too large, will be corrected | 213 expiration: "20 days", // Too large, will be corrected |
212 randomResult: 0.5, | 214 randomResult: 0.5, |
213 requests: [0.1, 14 * 24 + 0.1] | 215 requests: [0 + initialDelay, 14 * 24 + initialDelay] |
214 }, | 216 }, |
215 { | 217 { |
216 expiration: "35 hours", | 218 expiration: "35 hours", |
217 randomResult: 0, // Changes interval by factor 0.8 | 219 randomResult: 0, // Changes interval by factor 0.8 |
218 requests: [0.1, 28.1] | 220 requests: [0 + initialDelay, 28 + initialDelay] |
219 }, | 221 }, |
220 { | 222 { |
221 expiration: "35 hours", | 223 expiration: "35 hours", |
222 randomResult: 1, // Changes interval by factor 1.2 | 224 randomResult: 1, // Changes interval by factor 1.2 |
223 requests: [0.1, 42.1] | 225 requests: [0 + initialDelay, 42 + initialDelay] |
224 }, | 226 }, |
225 { | 227 { |
226 expiration: "35 hours", | 228 expiration: "35 hours", |
227 randomResult: 0.25, // Changes interval by factor 0.9 | 229 randomResult: 0.25, // Changes interval by factor 0.9 |
228 requests: [0.1, 32.1] | 230 requests: [0 + initialDelay, 32 + initialDelay] |
229 }, | 231 }, |
230 { | 232 { |
231 expiration: "40 hours", | 233 expiration: "40 hours", |
232 randomResult: 0.5, | 234 randomResult: 0.5, |
233 skipAfter: 5.1, | 235 skipAfter: 5 + initialDelay, |
234 skip: 10, // Short break should not increase soft expirati
on | 236 skip: 10, // Short break should not increase soft expirati
on |
235 requests: [0.1, 40.1] | 237 requests: [0 + initialDelay, 40 + initialDelay] |
236 }, | 238 }, |
237 { | 239 { |
238 expiration: "40 hours", | 240 expiration: "40 hours", |
239 randomResult: 0.5, | 241 randomResult: 0.5, |
240 skipAfter: 5.1, | 242 skipAfter: 5 + initialDelay, |
241 skip: 30, // Long break should increase soft expiration | 243 skip: 30, // Long break should increase soft expiration |
242 requests: [0.1, 70.1] | 244 requests: [0 + initialDelay, 70 + initialDelay] |
243 }, | 245 }, |
244 { | 246 { |
245 expiration: "40 hours", | 247 expiration: "40 hours", |
246 randomResult: 0.5, | 248 randomResult: 0.5, |
247 skipAfter: 5.1, | 249 skipAfter: 5 + initialDelay, |
248 skip: 80, // Hitting hard expiration, immediate download | 250 skip: 80, // Hitting hard expiration, immediate download |
249 requests: [0.1, 85.1] | 251 requests: [0 + initialDelay, 85 + initialDelay] |
250 } | 252 } |
251 ] | 253 ] |
252 | 254 |
253 for (test of tests) | 255 for (test of tests) |
254 { | 256 { |
255 requests = []; | 257 requests = []; |
256 randomResult = test.randomResult; | 258 randomResult = test.randomResult; |
257 resetSubscription(subscription); | 259 resetSubscription(subscription); |
258 | 260 |
259 let maxHours = Math.round(Math.max.apply(null, test.requests)) + 1; | 261 let maxHours = Math.round(Math.max.apply(null, test.requests)) + 1; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 let requests = []; | 350 let requests = []; |
349 testRunner.registerHandler("/redirected", function(metadata) | 351 testRunner.registerHandler("/redirected", function(metadata) |
350 { | 352 { |
351 requests.push(testRunner.getTimeOffset()); | 353 requests.push(testRunner.getTimeOffset()); |
352 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n! Expires: 8 hours\nbar"]; | 354 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n! Expires: 8 hours\nbar"]; |
353 }); | 355 }); |
354 | 356 |
355 resetSubscription(subscription); | 357 resetSubscription(subscription); |
356 testRunner.runScheduledTasks(15); | 358 testRunner.runScheduledTasks(15); |
357 equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "
Redirect followed"); | 359 equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "
Redirect followed"); |
358 deepEqual(requests, [0.1, 8.1], "Resulting requests"); | 360 deepEqual(requests, [0 + initialDelay, 8 + initialDelay], "Resulting request
s"); |
359 | 361 |
360 testRunner.registerHandler("/redirected", function(metadata) | 362 testRunner.registerHandler("/redirected", function(metadata) |
361 { | 363 { |
362 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Redirect: http://example.com/subs
cription\nbar"]; | 364 return [Cr.NS_OK, 200, "[Adblock]\nfoo\n!Redirect: http://example.com/subs
cription\nbar"]; |
363 }) | 365 }) |
364 | 366 |
365 subscription = Subscription.fromURL("http://example.com/subscription"); | 367 subscription = Subscription.fromURL("http://example.com/subscription"); |
366 resetSubscription(subscription); | 368 resetSubscription(subscription); |
367 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); | 369 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); |
368 FilterStorage.addSubscription(subscription); | 370 FilterStorage.addSubscription(subscription); |
(...skipping 14 matching lines...) Expand all Loading... |
383 // No valid response from fallback | 385 // No valid response from fallback |
384 | 386 |
385 let requests = []; | 387 let requests = []; |
386 testRunner.registerHandler("/subscription", function(metadata) | 388 testRunner.registerHandler("/subscription", function(metadata) |
387 { | 389 { |
388 requests.push(testRunner.getTimeOffset()); | 390 requests.push(testRunner.getTimeOffset()); |
389 return [Cr.NS_OK, 404, ""]; | 391 return [Cr.NS_OK, 404, ""]; |
390 }); | 392 }); |
391 | 393 |
392 testRunner.runScheduledTasks(100); | 394 testRunner.runScheduledTasks(100); |
393 deepEqual(requests, [0.1, 24.1, 48.1, 72.1, 96.1], "Continue trying if the f
allback doesn't respond"); | 395 deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay,
72 + initialDelay, 96 + initialDelay], "Continue trying if the fallback doesn't
respond"); |
394 | 396 |
395 // Fallback giving "Gone" response | 397 // Fallback giving "Gone" response |
396 | 398 |
397 resetSubscription(subscription); | 399 resetSubscription(subscription); |
398 requests = []; | 400 requests = []; |
399 fallbackParams = null; | 401 fallbackParams = null; |
400 testRunner.registerHandler("/fallback", function(metadata) | 402 testRunner.registerHandler("/fallback", function(metadata) |
401 { | 403 { |
402 fallbackParams = decodeURIComponent(metadata.queryString); | 404 fallbackParams = decodeURIComponent(metadata.queryString); |
403 return [Cr.NS_OK, 200, "410 Gone"]; | 405 return [Cr.NS_OK, 200, "410 Gone"]; |
404 }); | 406 }); |
405 | 407 |
406 testRunner.runScheduledTasks(100); | 408 testRunner.runScheduledTasks(100); |
407 deepEqual(requests, [0.1, 24.1, 48.1], "Stop trying if the fallback responds
with Gone"); | 409 deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay]
, "Stop trying if the fallback responds with Gone"); |
408 equal(fallbackParams, "http://example.com/subscription&0&404", "Fallback arg
uments"); | 410 equal(fallbackParams, "http://example.com/subscription&0&404", "Fallback arg
uments"); |
409 | 411 |
410 // Fallback redirecting to a missing file | 412 // Fallback redirecting to a missing file |
411 | 413 |
412 subscription = Subscription.fromURL("http://example.com/subscription"); | 414 subscription = Subscription.fromURL("http://example.com/subscription"); |
413 resetSubscription(subscription); | 415 resetSubscription(subscription); |
414 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); | 416 FilterStorage.removeSubscription(FilterStorage.subscriptions[0]); |
415 FilterStorage.addSubscription(subscription); | 417 FilterStorage.addSubscription(subscription); |
416 requests = []; | 418 requests = []; |
417 | 419 |
418 testRunner.registerHandler("/fallback", function(metadata) | 420 testRunner.registerHandler("/fallback", function(metadata) |
419 { | 421 { |
420 return [Cr.NS_OK, 200, "301 http://example.com/redirected"]; | 422 return [Cr.NS_OK, 200, "301 http://example.com/redirected"]; |
421 }); | 423 }); |
422 testRunner.runScheduledTasks(100); | 424 testRunner.runScheduledTasks(100); |
423 equal(FilterStorage.subscriptions[0].url, "http://example.com/subscription",
"Ignore invalid redirect from fallback"); | 425 equal(FilterStorage.subscriptions[0].url, "http://example.com/subscription",
"Ignore invalid redirect from fallback"); |
424 deepEqual(requests, [0.1, 24.1, 48.1, 72.1, 96.1], "Requests not affected by
invalid redirect"); | 426 deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay,
72 + initialDelay, 96 + initialDelay], "Requests not affected by invalid redire
ct"); |
425 | 427 |
426 // Fallback redirecting to an existing file | 428 // Fallback redirecting to an existing file |
427 | 429 |
428 resetSubscription(subscription); | 430 resetSubscription(subscription); |
429 requests = []; | 431 requests = []; |
430 let redirectedRequests = []; | 432 let redirectedRequests = []; |
431 testRunner.registerHandler("/redirected", function(metadata) | 433 testRunner.registerHandler("/redirected", function(metadata) |
432 { | 434 { |
433 redirectedRequests.push(testRunner.getTimeOffset()); | 435 redirectedRequests.push(testRunner.getTimeOffset()); |
434 return [Cr.NS_OK, 200, "[Adblock]\n!Expires: 1day\nfoo\nbar"]; | 436 return [Cr.NS_OK, 200, "[Adblock]\n!Expires: 1day\nfoo\nbar"]; |
435 }); | 437 }); |
436 | 438 |
437 testRunner.runScheduledTasks(100); | 439 testRunner.runScheduledTasks(100); |
438 equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "
Valid redirect from fallback is followed"); | 440 equal(FilterStorage.subscriptions[0].url, "http://example.com/redirected", "
Valid redirect from fallback is followed"); |
439 deepEqual(requests, [0.1, 24.1, 48.1], "Stop polling original URL after a va
lid redirect from fallback"); | 441 deepEqual(requests, [0 + initialDelay, 24 + initialDelay, 48 + initialDelay]
, "Stop polling original URL after a valid redirect from fallback"); |
440 deepEqual(redirectedRequests, [48.1, 72.1, 96.1], "Request new URL after a v
alid redirect from fallback"); | 442 deepEqual(redirectedRequests, [48 + initialDelay, 72 + initialDelay, 96 + in
itialDelay], "Request new URL after a valid redirect from fallback"); |
441 | 443 |
442 // Checksum mismatch | 444 // Checksum mismatch |
443 | 445 |
444 testRunner.registerHandler("/subscription", function(metadata) | 446 testRunner.registerHandler("/subscription", function(metadata) |
445 { | 447 { |
446 return [Cr.NS_OK, 200, "[Adblock]\n! Checksum: wrong\nfoo\nbar"]; | 448 return [Cr.NS_OK, 200, "[Adblock]\n! Checksum: wrong\nfoo\nbar"]; |
447 }); | 449 }); |
448 | 450 |
449 subscription = Subscription.fromURL("http://example.com/subscription"); | 451 subscription = Subscription.fromURL("http://example.com/subscription"); |
450 resetSubscription(subscription); | 452 resetSubscription(subscription); |
(...skipping 30 matching lines...) Expand all Loading... |
481 | 483 |
482 testRunner.registerHandler("/subscription", function(metadata) | 484 testRunner.registerHandler("/subscription", function(metadata) |
483 { | 485 { |
484 return [Cr.NS_OK, 200, "[Adblock]\n! Expires: 2 hours\nfoo\nbar"]; | 486 return [Cr.NS_OK, 200, "[Adblock]\n! Expires: 2 hours\nfoo\nbar"]; |
485 }); | 487 }); |
486 | 488 |
487 let startTime = testRunner.currentTime; | 489 let startTime = testRunner.currentTime; |
488 testRunner.runScheduledTasks(2); | 490 testRunner.runScheduledTasks(2); |
489 | 491 |
490 equal(subscription.downloadStatus, "synchronize_ok", "downloadStatus after s
uccessful download"); | 492 equal(subscription.downloadStatus, "synchronize_ok", "downloadStatus after s
uccessful download"); |
491 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + 0.1 * MILLIS
_IN_HOUR, "lastDownload after successful download"); | 493 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + initialDela
y * MILLIS_IN_HOUR, "lastDownload after successful download"); |
492 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + 0.1 * MILLIS_
IN_HOUR, "lastSuccess after successful download"); | 494 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialDelay
* MILLIS_IN_HOUR, "lastSuccess after successful download"); |
493 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + 1.1 * MILLIS_IN
_HOUR, "lastCheck after successful download"); | 495 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (1 + initialDe
lay) * MILLIS_IN_HOUR, "lastCheck after successful download"); |
494 equal(subscription.errors, 0, "errors after successful download"); | 496 equal(subscription.errors, 0, "errors after successful download"); |
495 | 497 |
496 testRunner.registerHandler("/subscription", function(metadata) | 498 testRunner.registerHandler("/subscription", function(metadata) |
497 { | 499 { |
498 return [Cr.NS_ERROR_FAILURE, 0, ""]; | 500 return [Cr.NS_ERROR_FAILURE, 0, ""]; |
499 }); | 501 }); |
500 | 502 |
501 testRunner.runScheduledTasks(2); | 503 testRunner.runScheduledTasks(2); |
502 | 504 |
503 equal(subscription.downloadStatus, "synchronize_connection_error", "download
Status after connection error"); | 505 equal(subscription.downloadStatus, "synchronize_connection_error", "download
Status after connection error"); |
504 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + 2.1 * MILLIS
_IN_HOUR, "lastDownload after connection error"); | 506 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + (2 + initia
lDelay) * MILLIS_IN_HOUR, "lastDownload after connection error"); |
505 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + 0.1 * MILLIS_
IN_HOUR, "lastSuccess after connection error"); | 507 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialDelay
* MILLIS_IN_HOUR, "lastSuccess after connection error"); |
506 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + 3.1 * MILLIS_IN
_HOUR, "lastCheck after connection error"); | 508 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (3 + initialDel
ay) * MILLIS_IN_HOUR, "lastCheck after connection error"); |
507 equal(subscription.errors, 1, "errors after connection error"); | 509 equal(subscription.errors, 1, "errors after connection error"); |
508 | 510 |
509 testRunner.registerHandler("/subscription", function(metadata) | 511 testRunner.registerHandler("/subscription", function(metadata) |
510 { | 512 { |
511 return [Cr.NS_OK, 404, ""]; | 513 return [Cr.NS_OK, 404, ""]; |
512 }); | 514 }); |
513 | 515 |
514 testRunner.runScheduledTasks(24); | 516 testRunner.runScheduledTasks(24); |
515 | 517 |
516 equal(subscription.downloadStatus, "synchronize_connection_error", "download
Status after download error"); | 518 equal(subscription.downloadStatus, "synchronize_connection_error", "download
Status after download error"); |
517 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + 26.1 * MILLI
S_IN_HOUR, "lastDownload after download error"); | 519 equal(subscription.lastDownload * MILLIS_IN_SECOND, startTime + (26 + initia
lDelay) * MILLIS_IN_HOUR, "lastDownload after download error"); |
518 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + 0.1 * MILLIS_
IN_HOUR, "lastSuccess after download error"); | 520 equal(subscription.lastSuccess * MILLIS_IN_SECOND, startTime + initialDelay
* MILLIS_IN_HOUR, "lastSuccess after download error"); |
519 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + 27.1 * MILLIS_I
N_HOUR, "lastCheck after download error"); | 521 equal(subscription.lastCheck * MILLIS_IN_SECOND, startTime + (27 + initialDe
lay) * MILLIS_IN_HOUR, "lastCheck after download error"); |
520 equal(subscription.errors, 2, "errors after download error"); | 522 equal(subscription.errors, 2, "errors after download error"); |
521 }); | 523 }); |
522 })(); | 524 })(); |
OLD | NEW |