@@ -98,7 +98,7 @@ bool TimeoutManager::IsBackground() const {
9898
9999bool TimeoutManager::IsActive () const {
100100 // A window/worker is considered active if:
101- // * It is a chrome window
101+ // * It is a chrome window/worker
102102 // * It is playing audio
103103 //
104104 // Note that a window/worker can be considered active if it is either in the
@@ -109,6 +109,10 @@ bool TimeoutManager::IsActive() const {
109109 return true ;
110110 }
111111
112+ if (mIsChromeWorker ) {
113+ return true ;
114+ }
115+
112116 // Check if we're playing audio
113117 if (mGlobalObject .IsPlayingAudio ()) {
114118 return true ;
@@ -326,7 +330,8 @@ TimeDuration TimeoutManager::CalculateDelay(Timeout* aTimeout) const {
326330 TimeDuration result = aTimeout->mInterval ;
327331
328332 if (aTimeout->mNestingLevel >=
329- StaticPrefs::dom_clamp_timeout_nesting_level ()) {
333+ StaticPrefs::dom_clamp_timeout_nesting_level () &&
334+ !mIsChromeWorker ) {
330335 uint32_t minTimeoutValue = StaticPrefs::dom_min_timeout_value ();
331336 result = TimeDuration::Max (result,
332337 TimeDuration::FromMilliseconds (minTimeoutValue));
@@ -408,7 +413,8 @@ uint32_t TimeoutManager::sNestingLevel = 0;
408413
409414TimeoutManager::TimeoutManager (nsIGlobalObject& aHandle,
410415 uint32_t aMaxIdleDeferMS,
411- nsISerialEventTarget* aEventTarget)
416+ nsISerialEventTarget* aEventTarget,
417+ bool aIsChromeWorker)
412418 : mGlobalObject(aHandle),
413419 mExecutor(new TimeoutExecutor(this , false , 0 )),
414420 mIdleExecutor(new TimeoutExecutor(this , true , aMaxIdleDeferMS)),
@@ -429,7 +435,8 @@ TimeoutManager::TimeoutManager(nsIGlobalObject& aHandle,
429435 mBudgetThrottleTimeouts(false ),
430436 mIsLoading(false ),
431437 mEventTarget(aEventTarget),
432- mIsWindow(aHandle.GetAsInnerWindow()) {
438+ mIsWindow(aHandle.GetAsInnerWindow()),
439+ mIsChromeWorker(aIsChromeWorker) {
433440 MOZ_LOG (gTimeoutLog , LogLevel::Debug,
434441 (" TimeoutManager %p created, tracking bucketing %s\n " , this ,
435442 StaticPrefs::privacy_trackingprotection_annotate_channels ()
0 commit comments