Add failing spec for webview visiblity changes

This commit is contained in:
Kevin Sawicki 2016-05-24 12:37:26 -07:00
parent b86ded3b54
commit 1e15ce6ccd
3 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,11 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
const {ipcRenderer} = require('electron')
ipcRenderer.send('pong', document.visibilityState, document.hidden)
document.addEventListener('visibilitychange', function () {
ipcRenderer.send('pong', document.visibilityState, document.hidden)
})
</script>
</body>
</html>

View file

@ -0,0 +1,8 @@
<html>
<body>
<script>
console.log(document.visibilityState, document.hidden)
</script>
<webview nodeintegration src="visibilitychange.html"/>
</body>
</html>

View file

@ -867,4 +867,25 @@ describe('<webview> tag', function () {
})
w.loadURL('file://' + fixtures + '/pages/webview-zoom-factor.html')
})
it('has the initial hidden state and receives visibilitychange events', function (done) {
w = new BrowserWindow({
show: false
})
ipcMain.once('pong', function (event, visibilityState, hidden) {
assert.equal(visibilityState, 'hidden')
assert.equal(hidden, true)
w.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', 'visible')
ipcMain.once('pong', function (event, visibilityState, hidden) {
assert.equal(visibilityState, 'visible')
assert.equal(hidden, false)
done()
})
})
w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html')
})
})