From 071201d86e76ebb7108f3ae7054466fdfc22dc1e Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 14 Apr 2022 16:17:30 +0000 Subject: [PATCH] Bug 1735042 [wpt PR 31177] - Tests for requestIdleCallback deadline computation, a=testonly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic update from web-platform-tests Tests for requestIdleCallback deadline computation (#31177) * Tests for requestIdleCallback deadline computation Deadline should be: - capped at 50ms - capped at 1000/60 (~16ms) when there is a pending rAF callback - capped at the time of the next timeout - be updated when the above conditions change, during the callback itself See https://github.com/whatwg/html/pull/7166 Co-authored-by: Philip Jägenstedt -- wpt-commits: 6ae31b2052754cb7645ba0e4c7c8ec43681d4a36 wpt-pr: 31177 --- .../deadline-max-rAF-dynamic.html | 31 +++++++++++++++++++ .../requestidlecallback/deadline-max-rAF.html | 21 +++++++++++++ .../deadline-max-timeout-dynamic.html | 31 +++++++++++++++++++ .../requestidlecallback/deadline-max.html | 20 ++++++++++++ .../resources/ric-utils.js | 14 +++++++++ 5 files changed, 117 insertions(+) create mode 100644 testing/web-platform/tests/requestidlecallback/deadline-max-rAF-dynamic.html create mode 100644 testing/web-platform/tests/requestidlecallback/deadline-max-rAF.html create mode 100644 testing/web-platform/tests/requestidlecallback/deadline-max-timeout-dynamic.html create mode 100644 testing/web-platform/tests/requestidlecallback/deadline-max.html create mode 100644 testing/web-platform/tests/requestidlecallback/resources/ric-utils.js diff --git a/testing/web-platform/tests/requestidlecallback/deadline-max-rAF-dynamic.html b/testing/web-platform/tests/requestidlecallback/deadline-max-rAF-dynamic.html new file mode 100644 index 000000000000..43eebd7641be --- /dev/null +++ b/testing/web-platform/tests/requestidlecallback/deadline-max-rAF-dynamic.html @@ -0,0 +1,31 @@ + +window.requestIdleCallback max idle period deadline (requestAnimationFrame). + + + + + + +

Test of requestIdleCallback deadline behavior

+

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. +It runs multiple times to expose potential failures.

+
diff --git a/testing/web-platform/tests/requestidlecallback/deadline-max-rAF.html b/testing/web-platform/tests/requestidlecallback/deadline-max-rAF.html new file mode 100644 index 000000000000..314f250254f9 --- /dev/null +++ b/testing/web-platform/tests/requestidlecallback/deadline-max-rAF.html @@ -0,0 +1,21 @@ + +window.requestIdleCallback max idle period deadline (requestAnimationFrame). + + + + + + +

Test of requestIdleCallback deadline behavior

+

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. +It runs multiple times to expose potential failures.

+
diff --git a/testing/web-platform/tests/requestidlecallback/deadline-max-timeout-dynamic.html b/testing/web-platform/tests/requestidlecallback/deadline-max-timeout-dynamic.html new file mode 100644 index 000000000000..169e6db54853 --- /dev/null +++ b/testing/web-platform/tests/requestidlecallback/deadline-max-timeout-dynamic.html @@ -0,0 +1,31 @@ + +window.requestIdleCallback max idle period deadline (dynamic timoeout). + + + + + + +

Test of requestIdleCallback deadline behavior

+

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. +It runs multiple times to expose potential failures.

+
diff --git a/testing/web-platform/tests/requestidlecallback/deadline-max.html b/testing/web-platform/tests/requestidlecallback/deadline-max.html new file mode 100644 index 000000000000..e33341ac9dd9 --- /dev/null +++ b/testing/web-platform/tests/requestidlecallback/deadline-max.html @@ -0,0 +1,20 @@ + +window.requestIdleCallback max idle period deadline. + + + + + + +

Test of requestIdleCallback deadline behavior

+

This test validates that deadlines returned for requestIdleCallback are less than 50ms.

+

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. +It runs multiple times to expose potential failures.

+
diff --git a/testing/web-platform/tests/requestidlecallback/resources/ric-utils.js b/testing/web-platform/tests/requestidlecallback/resources/ric-utils.js new file mode 100644 index 000000000000..d6d22767a98e --- /dev/null +++ b/testing/web-platform/tests/requestidlecallback/resources/ric-utils.js @@ -0,0 +1,14 @@ +function getDeadlineForNextIdleCallback() { + return new Promise( + resolve => + requestIdleCallback(deadline => resolve(deadline.timeRemaining())) + ); +} + +function getPendingRenderDeadlineCap() { + return 1000 / 60; +} + +function getRICRetryCount() { + return 10; +} \ No newline at end of file