Bug 1684139 - Exclude ChromeWorkers from setTimeout/setInterval clamping. r=asuth

Exclude the chrome workers from setTimeout clamping for workers.

Depends on D105332

Differential Revision: https://phabricator.services.mozilla.com/D106606
This commit is contained in:
Eden Chuang 2021-03-10 12:35:47 +00:00
Родитель 53093e432c
Коммит 25a83eafa2
1 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -967,7 +967,11 @@ class WorkerPrivate::EventTarget final : public nsISerialEventTarget {
struct WorkerPrivate::TimeoutInfo {
TimeoutInfo()
: mId(0), mNestingLevel(0), mIsInterval(false), mCanceled(false) {
: mId(0),
mNestingLevel(0),
mIsInterval(false),
mCanceled(false),
mOnChromeWorker(false) {
MOZ_COUNT_CTOR(mozilla::dom::WorkerPrivate::TimeoutInfo);
}
@ -991,7 +995,8 @@ struct WorkerPrivate::TimeoutInfo {
void CalculateTargetTime() {
auto target = mInterval;
if (mNestingLevel >= kClampTimeoutNestingLevel) {
// Don't clamp timeout for chrome workers
if (mNestingLevel >= kClampTimeoutNestingLevel && !mOnChromeWorker) {
target = TimeDuration::Max(
mInterval,
TimeDuration::FromMilliseconds(StaticPrefs::dom_min_timeout_value()));
@ -1006,6 +1011,7 @@ struct WorkerPrivate::TimeoutInfo {
uint32_t mNestingLevel;
bool mIsInterval;
bool mCanceled;
bool mOnChromeWorker;
};
class WorkerJSContextStats final : public JS::RuntimeStats {
@ -4563,6 +4569,7 @@ int32_t WorkerPrivate::SetTimeout(JSContext* aCx, TimeoutHandler* aHandler,
}
auto newInfo = MakeUnique<TimeoutInfo>();
newInfo->mOnChromeWorker = mIsChromeWorker;
newInfo->mIsInterval = aIsInterval;
newInfo->mId = timerId;
newInfo->AccumulateNestingLevel(data->mCurrentTimerNestingLevel);