Skip to content

Commit

Permalink
REGRESSION(266828@main): Nested setTimeout not being throttled in the…
Browse files Browse the repository at this point in the history
… background

https://bugs.webkit.org/show_bug.cgi?id=262086

Reviewed by Chris Dumez.

Only expect half of the timers to be throttled to avoid flakiness.

* LayoutTests/fast/dom/timer-throttling-hidden-page-2-expected.txt:
* LayoutTests/fast/dom/timer-throttling-hidden-page-2.html:

Canonical link: https://commits.webkit.org/268585@main
  • Loading branch information
rniwa committed Sep 28, 2023
1 parent fe502bf commit bdd0a56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
13 changes: 2 additions & 11 deletions LayoutTests/fast/dom/timer-throttling-hidden-page-2-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@ Tests that DOM timers gets throttled on hidden pages once they reach the max nes
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime < 100 is true
PASS timerEndTime - timerStartTime > 100 is true
PASS throttledCount > maxNestingLevel / 2 is true
PASS unthrottledCount > maxNestingLevel / 2 is true
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
18 changes: 14 additions & 4 deletions LayoutTests/fast/dom/timer-throttling-hidden-page-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
let timerHandle = 0;
let timerStartTime = 0;
let timerEndTime = 0;
const timerFiredTimes = [];

function testTimer()
{
Expand All @@ -19,14 +20,23 @@
timerEndTime = performance.now();

timerHandle = setTimeout(testTimer, timeoutInterval);
if (timerCount > maxNestingLevel) {
shouldBeTrue('timerEndTime - timerStartTime > 100');
timerFiredTimes.push(timerEndTime - timerStartTime);
if (timerCount > 2 * maxNestingLevel) {
unthrottledCount = 0;
throttledCount = 0;
for (let i = 0; i < timerCount; ++i) {
if (timerFiredTimes[i] < 300)
unthrottledCount++;
else
throttledCount++;
}
shouldBeTrue('throttledCount > maxNestingLevel / 2');
shouldBeTrue('unthrottledCount > maxNestingLevel / 2');
testRunner.resetPageVisibility();
clearTimeout(timerHandle);
finishJSTest();
return;
} else
shouldBeTrue('timerEndTime - timerStartTime < 100');
}
timerStartTime = timerEndTime;
}

Expand Down

0 comments on commit bdd0a56

Please sign in to comment.