0

It seems as though this may be a bug with the Blink engine itself, but when using JS similar to this

window.open(Location, '_blank');

The new window always has a visibility state of hidden, and it's very consistent. Sadly JS fiddle doesn't seem to work with this (iFrames break the bug maybe?), but I have a super basic test case here.

You'll see if you open my test html file, and Ctrl+Click on the button, the new tab that opens up will always be stuck in a hidden state, which you can check in the console like

> document.visibilityState
"hidden"
> document.hidden
true

This causes weird issues with things that check the visibility state of the page, and no amount of refreshing seems to fix it either, essentially once the tab starts that way, it never comes back out of that, although closing the tab and reopening with Ctrl+Shift+T does seem to make it behave correctly.

I noticed the bug using the Dark Reader extension, some of my tabs would never fully style correctly, and I think this is the culprit. Is this a bug? Is there a workaround so my own applications can load correctly whilst making sure the tab is visible?

Chrome version: 84.0.4147.105, Edge version: 84.0.522.44

Brian Leishman
  • 8,155
  • 11
  • 57
  • 93
  • looks like it's the case with every single tab opening method listed here https://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-and-not-a-new-window – Brian Leishman Jul 28 '20 at 15:42
  • I reproduced the issue in Edge Chromium and Chrome. From the [steps to determine the visibility state](https://www.w3.org/TR/page-visibility/#dfn-steps-to-determine-the-visibility-state), I think it should be `visible` when we switch to the newly opened tab. It works well if we open the new tab through a link. It looks like an issue with chromium. You can Report an issue (Alt+Shift+I) in Chrome or Send feedback (Alt+Shift+I) in Edge Chromium. Besides, what goal do you want to achieve using the Visibility API? Do you want to detect if the window is active or something? – Yu Zhou Jul 29 '20 at 07:12

0 Answers0