[tor-commits] [tor-browser/tor-browser-38.1.0esr-5.x-1] fixup! Bug 1517: Reduce precision of time for Javascript.

mikeperry at torproject.org mikeperry at torproject.org
Thu Jun 25 01:01:28 UTC 2015


commit 1dd1d5c72cecfdfbee6b8526553407d84724dbdd
Author: Mike Perry <mikeperry-git at torproject.org>
Date:   Wed Jun 24 17:50:31 2015 -0700

    fixup! Bug 1517: Reduce precision of time for Javascript.
    
    Address worker thread performance.now() and also clip dom highres timestamps
    at 1ms in other cases (such as requestAnimationFrame()).
---
 dom/base/nsDOMNavigationTiming.h |    2 +-
 dom/workers/Performance.cpp      |    5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/dom/base/nsDOMNavigationTiming.h b/dom/base/nsDOMNavigationTiming.h
index 7ae592c..e610891 100644
--- a/dom/base/nsDOMNavigationTiming.h
+++ b/dom/base/nsDOMNavigationTiming.h
@@ -91,7 +91,7 @@ public:
   inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp)
   {
     mozilla::TimeDuration duration = aStamp - mNavigationStartTimeStamp;
-    return duration.ToMilliseconds();
+    return floor(duration.ToMilliseconds()); // Clamp to milliseconds at least
   }
 
 private:
diff --git a/dom/workers/Performance.cpp b/dom/workers/Performance.cpp
index 366e3ab..8dea08b 100644
--- a/dom/workers/Performance.cpp
+++ b/dom/workers/Performance.cpp
@@ -34,9 +34,8 @@ Performance::WrapObject(JSContext* aCx)
 double
 Performance::Now() const
 {
-  TimeDuration duration =
-    TimeStamp::Now() - mWorkerPrivate->NowBaseTimeStamp();
-  return duration.ToMilliseconds();
+  TimeDuration duration = TimeStamp::Now() - mWorkerPrivate->NowBaseTimeStamp();
+  return floor(duration.ToMilliseconds()/100.0)*100.0;
 }
 
 END_WORKERS_NAMESPACE





More information about the tor-commits mailing list