Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-02-23 10:53:26 +08:00
commit 1804fcb5d1
10 changed files with 36 additions and 166 deletions

View file

@ -171,6 +171,8 @@ const nsIID kDEBUGWorkerEventTargetIID = {
// The number of nested timeouts before we start clamping. HTML says 5.
const uint32_t kClampTimeoutNestingLevel = 5u;
// The minimum interval we clamp timers in workers to. HTML says 4ms.
const uint32_t kClampTimeoutInterval = 4u;
template <class T>
class AutoPtrComparator
@ -1997,20 +1999,10 @@ struct WorkerPrivate::TimeoutInfo
void CalculateTargetTime(JSContext* aCx) {
auto target = mInterval;
int32_t minTimeoutValue;
// We're on a worker thread; go through WorkerPrivate for the pref.
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (workerPrivate) {
minTimeoutValue = workerPrivate->DOMMinTimeoutValue();
} else {
// fall back to default 4 ms
minTimeoutValue = 4;
}
// Clamp timeout for workers, except chrome workers
if (mNestingLevel >= kClampTimeoutNestingLevel && !mOnChromeWorker) {
target = TimeDuration::Max(mInterval,TimeDuration::FromMilliseconds(minTimeoutValue));
target = TimeDuration::Max(mInterval, TimeDuration::FromMilliseconds(kClampTimeoutInterval));
}
mTargetTime = TimeStamp::Now() + target;
}
@ -5169,7 +5161,9 @@ WorkerPrivate::ScheduleDeletion(WorkerRanOrNot aRanOrNot)
if (WorkerRan == aRanOrNot) {
nsIThread* currentThread = NS_GetCurrentThread();
MOZ_ASSERT(currentThread);
MOZ_ASSERT(!NS_HasPendingEvents(currentThread));
// On the worker thread WorkerRunnable will refuse to run if not nested
// on top of a WorkerThreadPrimaryRunnable.
Unused << NS_WARN_IF(NS_HasPendingEvents(currentThread));
}
#endif