Bug 1236036 - Automatically close native notifications in test_alerts.html. r?MattN draft
authorJoel Maher <jmaher@mozilla.com>
Fri, 15 Jan 2016 08:20:10 -0700
changeset 322008 e5840bbd7caf3b8e6b65a09afb4d06577593f26f
parent 322007 5429eeddddf2ece1bbf247d409fdbf9f4ebea92c
child 513013 93a864243a7230842dac7957564c59d4a50fcf5c
push id9508
push userkcambridge@mozilla.com
push dateFri, 15 Jan 2016 15:21:27 +0000
reviewersMattN
bugs1236036
milestone46.0a1
Bug 1236036 - Automatically close native notifications in test_alerts.html. r?MattN
toolkit/components/alerts/test/test_alerts.html
--- a/toolkit/components/alerts/test/test_alerts.html
+++ b/toolkit/components/alerts/test/test_alerts.html
@@ -60,20 +60,24 @@ function runTest() {
   try {
     var alertName = "fiorello";
     SimpleTest.waitForExplicitFinish();
     notifier.showAlertNotification(null, "Notification test",
                                    "Surprise! I'm here to test notifications!",
                                    false, "foobarcookie", observer, alertName);
     ok(true, "showAlertNotification() succeeded.  Waiting for notification...");
 
-    if (SpecialPowers.Services.appinfo.OS == "Darwin") {
-      // Notifications are native on OS X 10.8 and later, and when they are they
-      // persist in the Notification Center. We need to close explicitly to avoid a hang.
-      // This also works for XUL notifications when running this test on OS X < 10.8.
+    if ("@mozilla.org/system-alerts-service;1" in Cc) {
+      // Notifications are native on OS X 10.8 and later, as well as GNOME
+      // Shell with libnotify (bug 1236036). These notifications persist in the
+      // Notification Center, and only fire the `alertfinished` event when
+      // closed. For platforms where native notifications may be used, we need
+      // to close explicitly to avoid a hang. This also works for XUL
+      // notifications when running this test on OS X < 10.8, or a window
+      // manager like Ubuntu Unity with incomplete libnotify support.
       notifier.closeAlert(alertName);
     }
   } catch (ex) {
     todo(false, "showAlertNotification() failed.", ex);
     SimpleTest.finish();
   }
 }