diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index 7279b232a99d..5280f1927e80 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.isMinimized() || !currentWindow.isVisible() + +Object.defineProperty document, 'visibilityState', + get: -> + if document.hidden then "hidden" else "visible" diff --git a/spec/chromium-spec.coffee b/spec/chromium-spec.coffee index 5559c36eba89..d19933393f4f 100644 --- a/spec/chromium-spec.coffee +++ b/spec/chromium-spec.coffee @@ -45,6 +45,14 @@ describe 'chromium feature', -> done() w.loadURL url + it 'is set correctly when window is inactive', (done) -> + w = new BrowserWindow(show:false) + w.webContents.on 'ipc-message', (event, args) -> + assert.deepEqual args, ['hidden', false] + done() + w.showInactive() + w.loadURL url + xdescribe 'navigator.webkitGetUserMedia', -> it 'calls its callbacks', (done) -> @timeout 5000