diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index 7279b232a99d..15acbdd48bde 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -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.isFocused() || !currentWindow.isVisible() + +Object.defineProperty document, 'visibilityState', + get: -> + if document.hidden then "hidden" else "visible"