OLD | NEW |
1 (function() | 1 (function() |
2 { | 2 { |
3 let testRunner = null; | 3 let testRunner = null; |
4 let randomResult = 0.5; | 4 let randomResult = 0.5; |
5 | 5 |
6 let originalInfo; | 6 let originalInfo; |
7 let info = require("info"); | 7 let info = require("info"); |
8 | 8 |
9 function showNotifications(url) | 9 function showNotifications(url) |
10 { | 10 { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 }); | 289 }); |
290 testRunner.runScheduledTasks(1); | 290 testRunner.runScheduledTasks(1); |
291 | 291 |
292 equal(parameters, | 292 equal(parameters, |
293 "addonName=adblockpluschrome&addonVersion=1.4.1&application=chrome&app
licationVersion=27.0&platform=chromium&platformVersion=12.0&lastVersion=3&downlo
adCount=0", | 293 "addonName=adblockpluschrome&addonVersion=1.4.1&application=chrome&app
licationVersion=27.0&platform=chromium&platformVersion=12.0&lastVersion=3&downlo
adCount=0", |
294 "The correct parameters are sent to the server"); | 294 "The correct parameters are sent to the server"); |
295 }); | 295 }); |
296 | 296 |
297 test("Expiration interval", function() | 297 test("Expiration interval", function() |
298 { | 298 { |
| 299 let initialDelay = 1 / 60; |
299 let tests = [ | 300 let tests = [ |
300 { | 301 { |
301 randomResult: 0.5, | 302 randomResult: 0.5, |
302 requests: [0.2, 24.2, 48.2] | 303 requests: [initialDelay, initialDelay + 24, initialDelay + 48] |
303 }, | 304 }, |
304 { | 305 { |
305 randomResult: 0, // Changes interval by factor 0.8 (19.2 hours) | 306 randomResult: 0, // Changes interval by factor 0.8 (19.2 hours) |
306 requests: [0.2, 20.2, 40.2] | 307 requests: [initialDelay, initialDelay + 20, initialDelay + 40] |
307 }, | 308 }, |
308 { | 309 { |
309 randomResult: 1, // Changes interval by factor 1.2 (28.8 hours) | 310 randomResult: 1, // Changes interval by factor 1.2 (28.8 hours) |
310 requests: [0.2, 29.2, 58.2] | 311 requests: [initialDelay, initialDelay + 29, initialDelay + 58] |
311 }, | 312 }, |
312 { | 313 { |
313 randomResult: 0.25, // Changes interval by factor 0.9 (21.6 hours) | 314 randomResult: 0.25, // Changes interval by factor 0.9 (21.6 hours) |
314 requests: [0.2, 22.2, 44.2] | 315 requests: [initialDelay, initialDelay + 22, initialDelay + 44] |
315 }, | 316 }, |
316 { | 317 { |
317 randomResult: 0.5, | 318 randomResult: 0.5, |
318 skipAfter: 5.2, | 319 skipAfter: initialDelay + 5, |
319 skip: 10, // Short break should not increase soft expirati
on | 320 skip: 10, // Short break should not increase soft expirati
on |
320 requests: [0.2, 24.2] | 321 requests: [initialDelay, initialDelay + 24] |
321 }, | 322 }, |
322 { | 323 { |
323 randomResult: 0.5, | 324 randomResult: 0.5, |
324 skipAfter: 5.2, | 325 skipAfter: initialDelay + 5, |
325 skip: 30, // Long break should increase soft expiration, h
itting hard expiration | 326 skip: 30, // Long break should increase soft expiration, h
itting hard expiration |
326 requests: [0.2, 48.2] | 327 requests: [initialDelay, initialDelay + 48] |
327 } | 328 } |
328 ]; | 329 ]; |
329 | 330 |
330 let requests = []; | 331 let requests = []; |
331 registerHandler([], (metadata) => requests.push(testRunner.getTimeOffset()))
; | 332 registerHandler([], (metadata) => requests.push(testRunner.getTimeOffset()))
; |
332 for (let test of tests) | 333 for (let test of tests) |
333 { | 334 { |
334 Prefs.notificationdata = {}; | 335 Prefs.notificationdata = {}; |
335 requests = []; | 336 requests = []; |
336 randomResult = test.randomResult; | 337 randomResult = test.randomResult; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 equal(texts.message, "fr"); | 478 equal(texts.message, "fr"); |
478 }); | 479 }); |
479 | 480 |
480 test("Missing translation", function() | 481 test("Missing translation", function() |
481 { | 482 { |
482 let notification = {message: {"en-US": "en-US"}}; | 483 let notification = {message: {"en-US": "en-US"}}; |
483 let texts = Notification.getLocalizedTexts(notification, "fr"); | 484 let texts = Notification.getLocalizedTexts(notification, "fr"); |
484 equal(texts.message, "en-US"); | 485 equal(texts.message, "en-US"); |
485 }); | 486 }); |
486 })(); | 487 })(); |
OLD | NEW |