Visibility API is not working after window.open in Chrome
Asked Answered
B

1

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?

Basuto answered 5/8, 2020 at 11:30 Comment(2)
There are currently two open issues (1107556, 1019406) for the Visibility API that might be related.Ponceau
@Ponceau Unfortunately, both are not related. Thank you.Basuto
D
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.

Dubose answered 14/8, 2020 at 10:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.