Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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) { | 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 { | |
375 let relentless = { | 376 let relentless = { |
376 id: 3, | 377 id: 3, |
377 type: "relentless", | 378 type: "relentless", |
378 interval: 100 | 379 interval: 100 |
379 }; | 380 }; |
380 | 381 |
381 registerHandler.call(this, [relentless]); | 382 registerHandler.call(this, [relentless]); |
382 this.runScheduledTasks(1).then(() => | 383 this.runScheduledTasks(1).then(() => |
383 { | 384 { |
384 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are not shown initially"); | 385 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are 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 }).then(() => |
386 { | 387 { |
387 test.deepEqual(showNotifications(), [], "Relentless notifications are shown before interval"); | 388 test.deepEqual(showNotifications(), [], "Relentless notifications are not sh own before the interval"); |
388 }).then(() => | 389 }).then(() => |
389 { | 390 { |
390 // Date always returns a fixed time (see setupTimerAndXMLHttp) so we | 391 // Date always returns a fixed time (see setupTimerAndXMLHttp) so we |
391 // manipulate the shown data manually. | 392 // manipulate the shown data manually. |
392 Prefs.notificationdata.shown[relentless.id] -= relentless.interval; | 393 Prefs.notificationdata.shown[relentless.id] -= relentless.interval; |
393 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are not ignored"); | 394 test.deepEqual(showNotifications(), [relentless], "Relentless notifications are shown after the interval"); |
Felix Dahlke
2017/01/19 17:16:14
Description nit: "Relentless notifications are sho
wspee
2017/01/20 09:21:40
Done.
| |
395 }).catch(unexpectedError.bind(test)).then(() => test.done()); | |
396 }; | |
397 | |
398 exports.testRelentlessNotification = function(test) | |
399 { | |
400 let relentless = { | |
401 id: 3, | |
402 type: "relentless", | |
403 interval: 100, | |
404 urlFilters: ["foo.com$document", "bar.foo$document"] | |
405 }; | |
406 | |
407 registerHandler.call(this, [relentless]); | |
408 this.runScheduledTasks(1).then(() => | |
409 { | |
410 test.deepEqual(showNotifications(), [], "Relentless notification is not show n without URL"); | |
411 test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifica tion is not shown for a non-matching URL"); | |
412 test.deepEqual(showNotifications("http://foo.com"), [relentless], "Relentles s notification is shown for a matching URL"); | |
413 }).then(() => | |
414 { | |
415 test.deepEqual(showNotifications("http://foo.com"), [], "Relentless notifica tions are not shown before the interval"); | |
416 }).then(() => | |
417 { | |
418 // Date always returns a fixed time (see setupTimerAndXMLHttp) so we | |
419 // manipulate the shown data manually. | |
420 Prefs.notificationdata.shown[relentless.id] -= relentless.interval; | |
421 test.deepEqual(showNotifications(), [], "Relentless notifications are not sh own after the interval without URL"); | |
422 test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifica tions are not shown after the interval for a non-matching URL"); | |
423 test.deepEqual(showNotifications("http://bar.foo.com"), [relentless], "Relen tless notifications are shown after the interval for a matching URL"); | |
394 }).catch(unexpectedError.bind(test)).then(() => test.done()); | 424 }).catch(unexpectedError.bind(test)).then(() => test.done()); |
395 }; | 425 }; |
396 | 426 |
397 exports.testGlobalOptOut = function(test) | 427 exports.testGlobalOptOut = function(test) |
398 { | 428 { |
399 Notification.toggleIgnoreCategory("*", true); | 429 Notification.toggleIgnoreCategory("*", true); |
400 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out"); | 430 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out"); |
401 Notification.toggleIgnoreCategory("*", true); | 431 Notification.toggleIgnoreCategory("*", true); |
402 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out (again)"); | 432 test.ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enabl e global opt-out (again)"); |
403 Notification.toggleIgnoreCategory("*", false); | 433 Notification.toggleIgnoreCategory("*", false); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 test.done(); | 513 test.done(); |
484 }; | 514 }; |
485 | 515 |
486 exports.testMissingTranslation = function(test) | 516 exports.testMissingTranslation = function(test) |
487 { | 517 { |
488 let notification = {message: {"en-US": "en-US"}}; | 518 let notification = {message: {"en-US": "en-US"}}; |
489 let texts = Notification.getLocalizedTexts(notification, "fr"); | 519 let texts = Notification.getLocalizedTexts(notification, "fr"); |
490 test.equal(texts.message, "en-US"); | 520 test.equal(texts.message, "en-US"); |
491 test.done(); | 521 test.done(); |
492 }; | 522 }; |
LEFT | RIGHT |