Bug 674957 - mochitests-5: test_alerts.htmltimed out after 330 seconds. r=sdwilsh
authorBrian R. Bondy <netzen@gmail.com>
Wed, 21 Sep 2011 12:54:50 -0400
changeset 77273 0f45fa81734a73b5d2967bf575d0904fa5977525
parent 77272 519c7eed899afdf53c57c4a6b31b6f7be0f515e7
child 77274 02ce78afb98495d2ae5ed64f578751c7253bca61
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerssdwilsh
bugs674957
milestone9.0a1
Bug 674957 - mochitests-5: test_alerts.htmltimed out after 330 seconds. r=sdwilsh
toolkit/components/alerts/test/test_alerts.html
--- a/toolkit/components/alerts/test/test_alerts.html
+++ b/toolkit/components/alerts/test/test_alerts.html
@@ -17,61 +17,58 @@
 <br>If so, the test will finish once the notification disappears.
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 
 var observer = {
   observe: function (aSubject, aTopic, aData) {
-    if (aTopic == "alertclickcallback")
+    if (aTopic == "alertclickcallback") { 
       todo(false, "Did someone click the notification while running mochitests? (Please don't.)");
-    else
+    } else {
       is(aTopic, "alertfinished", "Checking the topic for a finished notification");
+    }
     is(aData, "foobarcookie", "Checking whether the alert cookie was passed correctly");
-
-    // finish(), yet let the test actually end first, to be safe.
-    SimpleTest.executeSoon(SimpleTest.finish);
+    SimpleTest.finish();
   }
 };
 
-const Cc = Components.classes;
-const Ci = Components.interfaces;
+function runTest() {
+  const Cc = Components.classes;
+  const Ci = Components.interfaces;
 
-var gNotificationIsAvailable;
+  if (!("@mozilla.org/alerts-service;1" in Cc)) {
+    todo(false, "Alerts service does not exist in this application");
+    return;
+  }
 
-if (!("@mozilla.org/alerts-service;1" in Cc)) {
-  todo(false, "Alerts service does not exist in this application");
-} else {
   ok(true, "Alerts service exists in this application");
 
   var notifier;
   try {
     notifier = Cc["@mozilla.org/alerts-service;1"].
                getService(Ci.nsIAlertsService);
     ok(true, "Alerts service is available");
   } catch (ex) {
-    todo(false, "Alerts service is not available. (Mac OS X without Growl?)", ex);
+    todo(false, 
+         "Alerts service is not available. (Mac OS X without Growl?)", ex);
+    return;
   }
 
-  if (notifier) {
-    try {
-      notifier.showAlertNotification(null, "Notification test",
-                                     "Surprise! I'm here to test notifications!",
-                                     false, "foobarcookie", observer);
-      ok(true, "showAlertNotification() succeeded");
-
-      gNotificationIsAvailable = true;
-    } catch (ex) {
-      todo(false, "showAlertNotification() failed. (Mac OS X without Growl?)", ex);
-    }
+  try {
+    SimpleTest.waitForExplicitFinish();
+    notifier.showAlertNotification(null, "Notification test",
+                                   "Surprise! I'm here to test notifications!",
+                                   false, "foobarcookie", observer);
+    ok(true, "showAlertNotification() succeeded.  Waiting for notification...");
+  } catch (ex) {
+    todo(false, "showAlertNotification() failed. (Mac OS X without Growl?)", ex);
+    SimpleTest.finish();
   }
 }
 
-if (gNotificationIsAvailable) {
-  // Wait for the (asynchronous) notification callback.
-  SimpleTest.waitForExplicitFinish();
-  ok(true, "Waiting for notification callback to be triggered...");
-}
+runTest();
+
 </script>
 </pre>
 </body>
 </html>