Left: | ||
Right: |
OLD | NEW |
---|---|
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 ]); | 364 ]); |
365 this.runScheduledTasks(1).then(() => | 365 this.runScheduledTasks(1).then(() => |
366 { | 366 { |
367 test.deepEqual(showNotifications(), [withoutURLFilter], "URL-specific notifi cations are skipped"); | 367 test.deepEqual(showNotifications(), [withoutURLFilter], "URL-specific notifi cations are skipped"); |
368 test.deepEqual(showNotifications("http://foo.com"), [withURLFilterFoo], "URL -specific notification is retrieved"); | 368 test.deepEqual(showNotifications("http://foo.com"), [withURLFilterFoo], "URL -specific notification is retrieved"); |
369 test.deepEqual(showNotifications("http://foo.com"), [], "URL-specific notifi cation is not retrieved"); | 369 test.deepEqual(showNotifications("http://foo.com"), [], "URL-specific notifi cation is not retrieved"); |
370 test.deepEqual(showNotifications("http://www.example.com"), [subdomainURLFil ter], "URL-specific notification matches subdomain"); | 370 test.deepEqual(showNotifications("http://www.example.com"), [subdomainURLFil ter], "URL-specific notification matches subdomain"); |
371 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 371 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
372 }; | 372 }; |
373 | 373 |
374 exports.testInterval = function(test) { | |
Felix Dahlke
2017/01/19 17:16:14
Nit: Opening brace should be on the next line
Felix Dahlke
2017/01/19 17:16:14
How about writing a second test that combines a re
wspee
2017/01/20 09:21:40
Done.
wspee
2017/01/20 09:21:40
Done.
| |
375 let relentless = { | |
376 id: 3, | |
377 type: "relentless", | |
378 interval: 100 | |
379 }; | |
380 | |
381 registerHandler.call(this, [relentless]); | |
382 this.runScheduledTasks(1).then(() => | |
383 { | |
384 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are not shown initially"); | |
Felix Dahlke
2017/01/19 17:16:14
Seems like the description here describes the situ
wspee
2017/01/20 09:21:40
Done.
| |
385 }).then(() => | |
386 { | |
387 test.deepEqual(showNotifications(), [], "Relentless notifications are shown before interval"); | |
388 }).then(() => | |
389 { | |
390 // Date always returns a fixed time (see setupTimerAndXMLHttp) so we | |
391 // manipulate the shown data manually. | |
392 Prefs.notificationdata.shown[relentless.id] -= relentless.interval; | |
393 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are not ignored"); | |
Felix Dahlke
2017/01/19 17:16:14
Description nit: "Relentless notifications are sho
wspee
2017/01/20 09:21:40
Done.
| |
394 }).catch(unexpectedError.bind(test)).then(() => test.done()); | |
395 }; | |
396 | |
374 exports.testGlobalOptOut = function(test) | 397 exports.testGlobalOptOut = function(test) |
375 { | 398 { |
376 Notification.toggleIgnoreCategory("*", true); | 399 Notification.toggleIgnoreCategory("*", true); |
377 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out"); | 400 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out"); |
378 Notification.toggleIgnoreCategory("*", true); | 401 Notification.toggleIgnoreCategory("*", true); |
379 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out (again)"); | 402 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out (again)"); |
380 Notification.toggleIgnoreCategory("*", false); | 403 Notification.toggleIgnoreCategory("*", false); |
381 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disab le global opt-out"); | 404 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disab le global opt-out"); |
382 Notification.toggleIgnoreCategory("*", false); | 405 Notification.toggleIgnoreCategory("*", false); |
383 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disab le global opt-out (again)"); | 406 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disab le global opt-out (again)"); |
(...skipping 11 matching lines...) Expand all Loading... | |
395 test.ok(Prefs.notifications_showui, "Opt-out UI will be shown after enabling g lobal opt-out even if it got disabled again"); | 418 test.ok(Prefs.notifications_showui, "Opt-out UI will be shown after enabling g lobal opt-out even if it got disabled again"); |
396 | 419 |
397 let information = { | 420 let information = { |
398 id: 1, | 421 id: 1, |
399 type: "information" | 422 type: "information" |
400 }; | 423 }; |
401 let critical = { | 424 let critical = { |
402 id: 2, | 425 id: 2, |
403 type: "critical" | 426 type: "critical" |
404 }; | 427 }; |
428 let relentless = { | |
429 id: 3, | |
430 type: "relentless" | |
431 }; | |
405 | 432 |
406 Notification.toggleIgnoreCategory("*", true); | 433 Notification.toggleIgnoreCategory("*", true); |
407 registerHandler.call(this, [information]); | 434 registerHandler.call(this, [information]); |
408 this.runScheduledTasks(1).then(() => | 435 this.runScheduledTasks(1).then(() => |
409 { | 436 { |
410 test.deepEqual(showNotifications(), [], "Information notifications are ignor ed after enabling global opt-out"); | 437 test.deepEqual(showNotifications(), [], "Information notifications are ignor ed after enabling global opt-out"); |
411 Notification.toggleIgnoreCategory("*", false); | 438 Notification.toggleIgnoreCategory("*", false); |
412 test.deepEqual(showNotifications(), [information], "Information notification s are shown after disabling global opt-out"); | 439 test.deepEqual(showNotifications(), [information], "Information notification s are shown after disabling global opt-out"); |
413 | 440 |
414 Notification.toggleIgnoreCategory("*", true); | 441 Notification.toggleIgnoreCategory("*", true); |
415 Prefs.notificationdata = {}; | 442 Prefs.notificationdata = {}; |
416 registerHandler.call(this, [critical]); | 443 registerHandler.call(this, [critical]); |
417 return this.runScheduledTasks(1); | 444 return this.runScheduledTasks(1); |
418 }).then(() => | 445 }).then(() => |
419 { | 446 { |
420 test.deepEqual(showNotifications(), [critical], "Critical notifications are not ignored"); | 447 test.deepEqual(showNotifications(), [critical], "Critical notifications are not ignored"); |
448 | |
449 Prefs.notificationdata = {}; | |
450 registerHandler.call(this, [relentless]); | |
451 return this.runScheduledTasks(1); | |
452 }).then(() => | |
453 { | |
454 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are not ignored"); | |
421 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 455 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
422 }; | 456 }; |
423 | 457 |
424 exports.testMessageWithoutLocalization = function(test) | 458 exports.testMessageWithoutLocalization = function(test) |
425 { | 459 { |
426 let notification = {message: "non-localized"}; | 460 let notification = {message: "non-localized"}; |
427 let texts = Notification.getLocalizedTexts(notification, "en-US"); | 461 let texts = Notification.getLocalizedTexts(notification, "en-US"); |
428 test.equal(texts.message, "non-localized"); | 462 test.equal(texts.message, "non-localized"); |
429 test.done(); | 463 test.done(); |
430 }; | 464 }; |
(...skipping 18 matching lines...) Expand all Loading... | |
449 test.done(); | 483 test.done(); |
450 }; | 484 }; |
451 | 485 |
452 exports.testMissingTranslation = function(test) | 486 exports.testMissingTranslation = function(test) |
453 { | 487 { |
454 let notification = {message: {"en-US": "en-US"}}; | 488 let notification = {message: {"en-US": "en-US"}}; |
455 let texts = Notification.getLocalizedTexts(notification, "fr"); | 489 let texts = Notification.getLocalizedTexts(notification, "fr"); |
456 test.equal(texts.message, "en-US"); | 490 test.equal(texts.message, "en-US"); |
457 test.done(); | 491 test.done(); |
458 }; | 492 }; |
OLD | NEW |