javascriptgoogle-chromevisibilitychange

Visibility API is not working after window.open in Chrome


I was trying to use Visibility API, but it is not working for a child. The minimal example to reproduce:

<script>

document.onvisibilitychange = () => {
      console.log(document.visibilityState);
    }

if (!window.opener) {
    window.open(window.location.href, '_blank');
}

</script>

After that, the parent window still prints "visible"-"hidden", but child prints "hidden" once only on refresh.

It works fine in the latest Opera browser, but not in the Chrome

To be honest, when I came to this minimal reproduce, I'm stuck and have no idea where to dig. Any ideas what could be wrong?


Solution

  • I also stumbled over this issue. I think that this bug was introduced in Chrome 84. I testet it with version 83 and it worked as expected. The current Canary-Build (Version 86) is also working.