mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1186489. Apply the performance.now() resolution clamping in workers as well. r=froydnj
This commit is contained in:
parent
f6c9647300
commit
596c29aaff
@ -502,8 +502,9 @@ DOMHighResTimeStamp
|
||||
nsPerformance::Now() const
|
||||
{
|
||||
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.
|
||||
// Round down to the nearest 5us, because if the timer is too accurate people
|
||||
// can do nasty timing attacks with it. See similar code in the worker
|
||||
// Performance implementation.
|
||||
const double maxResolutionMs = 0.005;
|
||||
return floor(nowTimeMs / maxResolutionMs) * maxResolutionMs;
|
||||
}
|
||||
|
@ -33,7 +33,12 @@ Performance::Now() const
|
||||
{
|
||||
TimeDuration duration =
|
||||
TimeStamp::Now() - mWorkerPrivate->NowBaseTimeStamp();
|
||||
return duration.ToMilliseconds();
|
||||
double nowTime = duration.ToMilliseconds();
|
||||
// Round down to the nearest 5us, because if the timer is too accurate people
|
||||
// can do nasty timing attacks with it. See similar code in the non-worker
|
||||
// Performance implementation.
|
||||
const double maxResolutionMs = 0.005;
|
||||
return floor(nowTime / maxResolutionMs) * maxResolutionMs;
|
||||
}
|
||||
|
||||
// To be removed once bug 1124165 lands
|
||||
|
Loading…
Reference in New Issue
Block a user