Bug 740769. (Av1) Fix multiple issues in test_bug325418.js. r=bzbarsky.
authorSerge Gautherie <sgautherie.bz@free.fr>
Thu, 05 Apr 2012 22:59:38 +0200
changeset 94389 da0d07b5ca1e79037eb66bad22bd2b3aeb106dc8
parent 94388 b7adf1bde2f668ed80e59b01fbf2a8e6fb9c021b
child 94390 ad90865125a22a0613618ad7e671b12ba066feb4
child 94460 fba572626884ec5981b894c19dd48aaddb65d779
child 94695 579f1d93491c059a42ee7a36f0c7234adf2fc5c3
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs740769, 325418
milestone14.0a1
first release with
nightly linux32
da0d07b5ca1e / 14.0a1 / 20120406031222 / files
nightly linux64
da0d07b5ca1e / 14.0a1 / 20120406031222 / files
nightly mac
da0d07b5ca1e / 14.0a1 / 20120406031222 / files
nightly win32
da0d07b5ca1e / 14.0a1 / 20120406031222 / files
nightly win64
da0d07b5ca1e / 14.0a1 / 20120406031222 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 740769. (Av1) Fix multiple issues in test_bug325418.js. r=bzbarsky.
xpcom/tests/unit/test_bug325418.js
--- a/xpcom/tests/unit/test_bug325418.js
+++ b/xpcom/tests/unit/test_bug325418.js
@@ -1,27 +1,26 @@
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 
 var timer;
 const start_time = (new Date()).getTime();
 const expected_time = 1;
 
 var observer = {
-  observe: function(subject, topic, data) {
+  observe: function observeTC(subject, topic, data) {
     if (topic == "timer-callback") {
-      var stop_time = (new Date()).getTime();
+      timer.cancel();
+      timer = null;
+
       // expected time may not be exact so convert to seconds and round down.
-      var result = Math.round((stop_time - start_time) / 1000);
-      do_check_true(result, expected_time);
+      var result = Math.floor(((new Date()).getTime() - start_time) / 1000);
+      do_check_eq(result, expected_time);
 
       do_test_finished();
-
-      timer.cancel();
-      timer = null;
     }
   }
 };
 
 function run_test() {
   do_test_pending();
 
   timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);