()
| 1983 | return; |
| 1984 | } |
| 1985 | function step() { |
| 1986 | // Race rAF against a setTimeout fallback. Headless Chromium throttles |
| 1987 | // and ultimately STOPS firing requestAnimationFrame when the page idles |
| 1988 | // (no compositing) -- which happens right after a form transition |
| 1989 | // completes and the worker's EDT parks on __cn1_wait_for_ui_settle__, |
| 1990 | // leaving nothing to drive a frame. Without the fallback this runFrame |
| 1991 | // chain never resolves, the host never replies, and the EDT parks |
| 1992 | // forever (the SlideHorizontalTransitionTest wall). The fallback |
| 1993 | // guarantees forward progress; when rAF is healthy it wins the race so |
| 1994 | // steady-state timing is unchanged. |
| 1995 | var advanced = false; |
| 1996 | function tick() { |
| 1997 | if (advanced) { |
| 1998 | return; |
| 1999 | } |
| 2000 | advanced = true; |
| 2001 | var idx = pendingFrameTicks.indexOf(tick); |
| 2002 | if (idx >= 0) { |
| 2003 | pendingFrameTicks.splice(idx, 1); |
| 2004 | } |
| 2005 | remaining--; |
| 2006 | if (remaining <= 0) { |
| 2007 | resolve(); |
| 2008 | return; |
| 2009 | } |
| 2010 | step(); |
| 2011 | } |
| 2012 | // Hidden/headless pages throttle BOTH rAF (stops entirely) and the |
| 2013 | // setTimeout fallback (intensive wake-up batching), so register the |
| 2014 | // tick for the external __cn1NudgeVm driver too -- a CDP-driven |
| 2015 | // nudge resolves pending frame waits within its interval instead of |
| 2016 | // stalling each settle for seconds. |
| 2017 | pendingFrameTicks.push(tick); |
| 2018 | raf(tick); |
| 2019 | setTimeout(tick, 32); |
| 2020 | } |
| 2021 | step(); |
| 2022 | }); |
| 2023 | } |
no test coverage detected