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

Unified Diff: chrome/content/tests/notification.js

Issue 5654617534758912: Issue 2237 - Added unit tests for notification opt-out (Closed)
Patch Set: Added extra tests Created May 28, 2015, 1:16 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/tests/notification.js
===================================================================
--- a/chrome/content/tests/notification.js
+++ b/chrome/content/tests/notification.js
@@ -33,6 +33,7 @@
Prefs.notificationurl = "http://example.com/notification.json";
Prefs.notificationdata = {};
+ Prefs.notifications_ignoredcategories = [];
// Replace Math.random() function
let DownloaderGlobal = Cu.getGlobalForObject(getModuleGlobal("downloader"));
@@ -376,6 +377,54 @@
deepEqual(Notification.getNextToShow("http://www.example.com"), subdomainURLFilter, "URL-specific notification matches subdomain");
});
+ test("Global opt-out", function()
+ {
+ Notification.toggleIgnoreCategory("*", true);
+ ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enable global opt-out");
+ Notification.toggleIgnoreCategory("*", true);
+ ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Force enable global opt-out (again)");
+ Notification.toggleIgnoreCategory("*", false);
+ ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disable global opt-out");
+ Notification.toggleIgnoreCategory("*", false);
+ ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Force disable global opt-out (again)");
+ Notification.toggleIgnoreCategory("*");
+ ok(Prefs.notifications_ignoredcategories.indexOf("*") != -1, "Toggle enable global opt-out");
+ Notification.toggleIgnoreCategory("*");
+ ok(Prefs.notifications_ignoredcategories.indexOf("*") == -1, "Toggle disable global opt-out");
+
+ Prefs.notifications_showui = false;
+ Notification.toggleIgnoreCategory("*", false);
+ ok(!Prefs.notifications_showui, "Opt-out UI will not be shown if global opt-out hasn't been enabled yet");
+ Notification.toggleIgnoreCategory("*", true);
+ ok(Prefs.notifications_showui, "Opt-out UI will be shown after enabling global opt-out");
+ Notification.toggleIgnoreCategory("*", false);
+ ok(Prefs.notifications_showui, "Opt-out UI will be shown after enabling global opt-out even if it got disabled again");
+
+ let information = fixConstructors({
+ id: 1,
+ type: "information"
+ });
+ let critical = fixConstructors({
+ id: 2,
+ type: "critical"
+ });
+
+ Notification.toggleIgnoreCategory("*", true);
+ registerHandler([information]);
+ testRunner.runScheduledTasks(1);
+
+ deepEqual(Notification.getNextToShow(), null, "Information notifications are ignored after enabling global opt-out");
+ Notification.toggleIgnoreCategory("*", false);
+ deepEqual(Notification.getNextToShow(), information, "Information notifications are shown after disabling global opt-out");
+
+ Notification.toggleIgnoreCategory("*", true);
+ Prefs.notificationdata = {};
+ registerHandler([critical]);
+ testRunner.runScheduledTasks(1);
+
+ deepEqual(Notification.getNextToShow(), critical, "Critical notifications are not ignored");
+ });
+
module("Notification localization");
test("Message without localization", function()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld