From fa09370f60f98ead35719a165c24fda89413dd7d Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Mon, 29 Aug 2022 17:11:11 +0000 Subject: [PATCH] Bug 1785549, ensure requestIdleCallback's callback doesn't get deadlines > 50ms, r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D155867 --- dom/base/IdleDeadline.cpp | 4 +++- .../meta/requestidlecallback/deadline-max.html.ini | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 testing/web-platform/meta/requestidlecallback/deadline-max.html.ini diff --git a/dom/base/IdleDeadline.cpp b/dom/base/IdleDeadline.cpp index 151e6765a3303..ac9cbdbe03ddc 100644 --- a/dom/base/IdleDeadline.cpp +++ b/dom/base/IdleDeadline.cpp @@ -60,7 +60,9 @@ DOMHighResTimeStamp IdleDeadline::TimeRemaining() { return 0.0; } - return std::max(mDeadline - performance->Now(), 0.0); + // The web API doesn't expect deadlines > 50ms, but conversion from the + // internal API may lead to some rounding errors. + return std::min(std::max(mDeadline - performance->Now(), 0.0), 50.0); } // If there's no window, we're in a system scope, and can just use diff --git a/testing/web-platform/meta/requestidlecallback/deadline-max.html.ini b/testing/web-platform/meta/requestidlecallback/deadline-max.html.ini deleted file mode 100644 index f8c1e54edf453..0000000000000 --- a/testing/web-platform/meta/requestidlecallback/deadline-max.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[deadline-max.html] - [Check that the deadline is less than 50ms.] - expected: - if (os == "linux") and debug and fission and not swgl: [PASS, FAIL] - if os == "mac": FAIL