If none of the solutions here worked for you, here's what finally solved it for me: I discovered that "Emulate a focused page" was enabled in Chrome DevTools few months ago and forgot about it. I was using DevTools to debug the visibilitychange event, but DevTools itself was preventing the event from firing by emulating constant focus. Two hours of my life gone.