modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.23k stars 297 forks source link

visibilityState no longer works with concurrency>1 after chrome 120 #2808

Open frankborden opened 2 months ago

frankborden commented 2 months ago

We have some code that uses visibilityState for reporting etc. When we upgraded our tests from Chrome 120 to 128/129, they started to fail and timeout, showing visibilityState surprisingly becomes "hidden" and likewise our focus/blur event get stopped causing additional failures. We found that forcing serial tests fixed this issue, but of course we would prefer to keep the concurrency for speed.

I made a simple reproduction with code like this in a click handler:

if (document.visibilityState === "visible") {
  this.count++;
}

and some tests that click the button and assert the count increase. The tests only pass with concurrency=1, but it used to work.