7

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?

A. Yushchenko
  • 105
  • 2
  • 5
  • 1
    There are currently [two open issues (1107556, 1019406)](https://bugs.chromium.org/p/chromium/issues/list?q=onvisibilitychange&can=2) for the Visibility API that might be related. – Andreas Aug 05 '20 at 12:10
  • @Andreas Unfortunately, both are not related. Thank you. – A. Yushchenko Aug 05 '20 at 12:24

1 Answers1

1

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.

Alex
  • 88
  • 7