(doc)
| 6 | * @return {VisibilityState_Enum} |
| 7 | */ |
| 8 | export function getDocumentVisibilityState(doc) { |
| 9 | // New API: `document.visibilityState` property. |
| 10 | const visibilityStateProp = getVendorJsPropertyName( |
| 11 | doc, |
| 12 | 'visibilityState', |
| 13 | true |
| 14 | ); |
| 15 | const visibilityStateValue = /** @type {*} */ (doc)[visibilityStateProp]; |
| 16 | if (visibilityStateValue) { |
| 17 | return visibilityStateValue; |
| 18 | } |
| 19 | |
| 20 | // Old API: `document.hidden` property. |
| 21 | const hiddenProp = getVendorJsPropertyName(doc, 'hidden', true); |
| 22 | if (hiddenProp in doc) { |
| 23 | const hiddenValue = /** @type {*} */ (doc)[hiddenProp]; |
| 24 | return hiddenValue |
| 25 | ? VisibilityState_Enum.HIDDEN |
| 26 | : VisibilityState_Enum.VISIBLE; |
| 27 | } |
| 28 | |
| 29 | return VisibilityState_Enum.VISIBLE; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Returns the value of "document.hidden" property. The reasons why it may |
no test coverage detected