Merge pull request #3865 from deepak1556/visibility_api_patch

browser: fix document.hidden value
This commit is contained in:
Cheng Zhao 2015-12-22 19:04:23 +08:00
commit c4931bb2d1
2 changed files with 16 additions and 2 deletions

View file

@ -118,6 +118,12 @@ Object.defineProperty window.history, 'length',
get: ->
getHistoryOperation 'length'
# Make document.hidden return the correct value.
# Make document.hidden and document.visibilityState return the correct value.
Object.defineProperty document, 'hidden',
get: -> !remote.getCurrentWindow().isVisible()
get: ->
currentWindow = remote.getCurrentWindow()
currentWindow.isMinimized() || !currentWindow.isVisible()
Object.defineProperty document, 'visibilityState',
get: ->
if document.hidden then "hidden" else "visible"