Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: test/notification.js

Issue 29370562: [adblockpluscore] Issue 4762 - Added "relentless" notification that shows up in intervals (Closed)
Left Patch Set: Added another testcase and fixed review comments Created Jan. 20, 2017, 9:19 a.m.
Right Patch Set: Adressed review comments Created Jan. 20, 2017, 10:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/notification.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 let relentless = { 400 let relentless = {
401 id: 3, 401 id: 3,
402 type: "relentless", 402 type: "relentless",
403 interval: 100, 403 interval: 100,
404 urlFilters: ["foo.com$document", "bar.foo$document"] 404 urlFilters: ["foo.com$document", "bar.foo$document"]
405 }; 405 };
406 406
407 registerHandler.call(this, [relentless]); 407 registerHandler.call(this, [relentless]);
408 this.runScheduledTasks(1).then(() => 408 this.runScheduledTasks(1).then(() =>
409 { 409 {
410 test.deepEqual(showNotifications(), [], "Relentless notification is not show n without url"); 410 test.deepEqual(showNotifications(), [], "Relentless notification is not show n without URL");
Felix Dahlke 2017/01/20 09:51:37 Nit: "url" -> "URL"?
wspee 2017/01/20 10:26:13 Done.
411 test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifica tion is not shown to the wrong url"); 411 test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifica tion is not shown for a non-matching URL");
Felix Dahlke 2017/01/20 09:51:36 Nit: "shown to the wrong url" -> "shown for a non-
wspee 2017/01/20 10:26:13 Done.
412 test.deepEqual(showNotifications("http://foo.com"), [relentless], "Relentles s notification is shown to correct url"); 412 test.deepEqual(showNotifications("http://foo.com"), [relentless], "Relentles s notification is shown for a matching URL");
Felix Dahlke 2017/01/20 09:51:37 Nit: "shown to correct url" "shown for a matching
wspee 2017/01/20 10:26:13 Done.
413 }).then(() => 413 }).then(() =>
414 { 414 {
415 test.deepEqual(showNotifications("http://foo.com"), [], "Relentless notifica tions are not shown before the interval"); 415 test.deepEqual(showNotifications("http://foo.com"), [], "Relentless notifica tions are not shown before the interval");
416 }).then(() => 416 }).then(() =>
417 { 417 {
418 // Date always returns a fixed time (see setupTimerAndXMLHttp) so we 418 // Date always returns a fixed time (see setupTimerAndXMLHttp) so we
419 // manipulate the shown data manually. 419 // manipulate the shown data manually.
420 Prefs.notificationdata.shown[relentless.id] -= relentless.interval; 420 Prefs.notificationdata.shown[relentless.id] -= relentless.interval;
421 test.deepEqual(showNotifications(), [], "Relentless notifications are not sh own after the interval without url"); 421 test.deepEqual(showNotifications(), [], "Relentless notifications are not sh own after the interval without URL");
Felix Dahlke 2017/01/20 09:51:37 Nit: "url" -> "URL"?
wspee 2017/01/20 10:26:13 Done.
422 test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifica tions are not shown after the interval to the wrong url"); 422 test.deepEqual(showNotifications("http://bar.com"), [], "Relentless notifica tions are not shown after the interval for a non-matching URL");
Felix Dahlke 2017/01/20 09:51:36 Nit: "to the wrong url" -> "for a non-matching URL
wspee 2017/01/20 10:26:13 Done.
423 test.deepEqual(showNotifications("http://bar.foo.com"), [relentless], "Relen tless notifications are shown after the interval to the correct url"); 423 test.deepEqual(showNotifications("http://bar.foo.com"), [relentless], "Relen tless notifications are shown after the interval for a matching URL");
Felix Dahlke 2017/01/20 09:51:37 Nit: "to the correct url" -> "for a matching URL"?
wspee 2017/01/20 10:26:13 Done.
424 }).catch(unexpectedError.bind(test)).then(() => test.done()); 424 }).catch(unexpectedError.bind(test)).then(() => test.done());
425 }; 425 };
426 426
427 exports.testGlobalOptOut = function(test) 427 exports.testGlobalOptOut = function(test)
428 { 428 {
429 Notification.toggleIgnoreCategory("*", true); 429 Notification.toggleIgnoreCategory("*", true);
430 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");
431 Notification.toggleIgnoreCategory("*", true); 431 Notification.toggleIgnoreCategory("*", true);
432 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)");
433 Notification.toggleIgnoreCategory("*", false); 433 Notification.toggleIgnoreCategory("*", false);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 test.done(); 513 test.done();
514 }; 514 };
515 515
516 exports.testMissingTranslation = function(test) 516 exports.testMissingTranslation = function(test)
517 { 517 {
518 let notification = {message: {"en-US": "en-US"}}; 518 let notification = {message: {"en-US": "en-US"}};
519 let texts = Notification.getLocalizedTexts(notification, "fr"); 519 let texts = Notification.getLocalizedTexts(notification, "fr");
520 test.equal(texts.message, "en-US"); 520 test.equal(texts.message, "en-US");
521 test.done(); 521 test.done();
522 }; 522 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld