Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visibilitychange and visibilityState doesn't work when using HTTP and DevTools is Open #42566

Open
3 of 6 tasks
jcubic opened this issue Nov 27, 2024 · 0 comments
Open
3 of 6 tasks

Comments

@jcubic
Copy link

jcubic commented Nov 27, 2024

Description

I've tried to write code that use both API and the even don't fire when you change tabs and the visibilityState is always 'visible'.

Steps to reproduce

  1. Write this code:
function in_focus() {
    return document.visibilityState === 'visible';
}
document.addEventListener("visibilitychange", () => {
     console.log('visibilitychange', in_focus());
});
  1. Open the page on one tab
  2. Open DevTools
  3. Switch tabs

Actual result

No logs in console until you close the DevTools before you switch tabs.

Expected result

The event should fire the document.visibilityState should change

Reproduces how often

Easily reproduced

Brave version (brave://version info)

  • Brave: 1.73.91 Chromium: 131.0.6778.85 (Oficjalna wersja) (64-bitowa)
  • Wersja: 35427fa72a008a7e861fa9828e07a0ba2cd46ebd
  • System operacyjny: Linux

Channel information

  • release (stable)
  • beta
  • nightly

Reproducibility

  • with Brave Shields disabled
  • with Brave Rewards disabled
  • in the latest version of Chrome

Miscellaneous information

It works fine in Google Chrome and Firefox

Additionally, document.hasFocus() doesn't work on localhost. It always returns true when DevTools is Open.

EDIT just checked if this is by chance not an issue with HTTP vs HTTPS, and It turns out the same issue happens on any host when a page is served via HTTP.

Here is reproduction: http://u.just.net.pl

To test the issue, open the page and switch tab and back and open dev tools. Do the same when dev tools is open.

EDIT 2: Just installing SSL certificate for localhost, and serving files with https don't solve the issue. visibilityState still don't change when dev tools is open.

@jcubic jcubic changed the title visibilitychange and visibilityState doesn't work when DevTools is Open visibilitychange and visibilityState doesn't work when using HTTP and DevTools is Open Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant