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: -> get: ->
getHistoryOperation 'length' getHistoryOperation 'length'
# Make document.hidden return the correct value. # Make document.hidden and document.visibilityState return the correct value.
Object.defineProperty document, 'hidden', 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"

View file

@ -45,6 +45,14 @@ describe 'chromium feature', ->
done() done()
w.loadURL url 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', -> xdescribe 'navigator.webkitGetUserMedia', ->
it 'calls its callbacks', (done) -> it 'calls its callbacks', (done) ->
@timeout 5000 @timeout 5000