The spec recently swapped the order of firing pagehide & updating visibility - previously we fire pagehide first then update visibility state. Now we should update visibility state first and then fire pagehide. See https://github.com/whatwg/html/pull/5928 for details.
Ahah funny. I have just implemented this in WebKit via Bug 151234 and purposefully did not use the ordering from the spec because it did not match the order in Firefox and Chrome. We even filed a bug against the spec and uploaded a PR: https://github.com/whatwg/html/pull/5928 Oh well. Let's wait and see what other browsers do. If Chrome and Firefox actually implement this, we will follow. But for now, our behavior is the safest one.
<rdar://problem/69826032>
Closing this for now until we get more data, per https://github.com/whatwg/html/pull/5949#pullrequestreview-500156401 :)