author | Boris Zbarsky <bzbarsky@mit.edu> |
Tue, 07 Jul 2015 17:37:50 -0400 | |
changeset 251799 | 48ae8b5e62abe33612418ccb073a00b4ce6bfcd5 |
parent 251798 | 007f1cea86fbca274283ed88165c8140a071cc89 |
child 251800 | e3a5dbe2d697f7b8d05ec8fd2af4025e7e407d50 |
push id | 61956 |
push user | bzbarsky@mozilla.com |
push date | Tue, 07 Jul 2015 21:38:28 +0000 |
treeherder | mozilla-inbound@e3a5dbe2d697 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | froydnj |
bugs | 1167489, 1153672 |
milestone | 42.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/base/nsPerformance.cpp +++ b/dom/base/nsPerformance.cpp @@ -496,17 +496,21 @@ nsPerformance::Navigation() mNavigation = new nsPerformanceNavigation(this); } return mNavigation; } DOMHighResTimeStamp nsPerformance::Now() const { - return GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now()); + double nowTimeMs = GetDOMTiming()->TimeStampToDOMHighRes(TimeStamp::Now()); + // Round down to the nearest 0.005ms (5us), because if the timer is too + // accurate people can do nasty timing attacks with it. + const double maxResolutionMs = 0.005; + return floor(nowTimeMs / maxResolutionMs) * maxResolutionMs; } JSObject* nsPerformance::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) { return PerformanceBinding::Wrap(cx, this, aGivenProto); }