Repository: electron
Issue: [Bug]: webview's document.visibilityState and document.hidden are unreliable
Labels: platform/linux,component/webview,bug :beetle:,11-x-y,12-x-y,13-x-y

### Preflight Checklist

I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a feature request that matches the one I want to file, without success.

### Electron Version

11.4.3 - 12.0.4 - 13.0.0-beta.8 - 13.0.0-beta.14

### What operating system are you using?

Other Linux

### Operating System Version

Fedora, but possibly also happens on other systems

### What arch are you using?

x64

### Last Known Working Electron version

none

### Expected Behavior

Webview hidden/visible state should be directly related to the visibility on the screen. It should also be possible to overwrite the default properties of `document.hidden` and `document.visibilityState` with a custom value.

### Actual Behavior

It seems to always be visible, even when `display` is set to `none` or when the window is minimized. The ONLY way I have currently discovered to make the visibility hidden is by maximizing the window, then minimizing it. After that it will then never switch back to visible again (see screenshot). Though may be there are ways to do it, but overall the API return value doesn't make any sense most of the time.
![image](https://user-images.githubusercontent.com/1696674/114923280-e99c0d00-9e2c-11eb-87b6-4c378d50de1c.png)
"set" is what we toggle the display to, "actual" is `document.visibilityState` inside the webview after the `visibilitychange` event fires. `document.hidden` is linked to visibilityState.

Overall the visibilityState seems extremely unreliable, so much so that I considered this workaround:
```js
document.__defineGetter__("visibilityState", () => "visible")
document.__defineGetter__("hidden", () => false)
​// Or alternatively
Object.defineProperty(document, "hidden", {value: false})
Object.defineProperty(document, "visibilityState", {value: "visible"})
```
Though even that doesn't work, because you are not allowed to overwrite this property. I'm considering opening a separate feature request for that, because I don't think it's relevant info for every site loaded into a webview to know this and I'm looking for a way to block this API altogether using mock data inside webviews. It would seem that I'm [not the only one](https://stackoverflow.com/questions/55975102/fake-document-visibilitystate-in-electron) who would like this functionality.

In 11.4.3 the state is stuck on "visible", and even when maximized then minimized it doesn't change at all. For 12.0.4, 13.0.0-beta.8 and 13.0.0-beta.14 the listed flow from the first screenshot is happening, in that it will be stuck on "visible" until that weird trick, after which it's stuck on "hidden" forever. Though this issue goes much further back, as [seen here in 2016](https://github.com/electron/electron/issues/4879), with someone also commenting in 2020 that this is still a problem.

### Testcase Gist URL

https://gist.github.com/Jelmerro/37b92f38f767d7942334f218c254cd1d