Add spec for webview visibility change on show

This commit is contained in:
Kevin Sawicki 2017-06-12 12:51:27 -07:00
Родитель ce0684aada
Коммит f1a72ad108
1 изменённых файлов: 38 добавлений и 13 удалений

Просмотреть файл

@ -1097,25 +1097,50 @@ describe('<webview> tag', function () {
}) })
}) })
it('inherits the parent window visibility state and receives visibilitychange events', function (done) { describe('document.visibilityState/hidden', function () {
w = new BrowserWindow({ afterEach(function () {
show: false ipcMain.removeAllListeners('pong')
}) })
ipcMain.once('pong', function (event, visibilityState, hidden) { it('updates when the window is shown after the ready-to-show event', function (done) {
assert.equal(visibilityState, 'hidden') w = new BrowserWindow({
assert.equal(hidden, true) show: false
ipcMain.once('pong', function (event, visibilityState, hidden) {
assert.equal(visibilityState, 'visible')
assert.equal(hidden, false)
done()
}) })
w.webContents.emit('-window-visibility-change', 'visible') w.once('ready-to-show', function () {
w.show()
})
ipcMain.on('pong', function (event, visibilityState, hidden) {
if (!hidden) {
assert.equal(visibilityState, 'visible')
done()
}
})
w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html')
}) })
w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html') it('inherits the parent window visibility 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)
ipcMain.once('pong', function (event, visibilityState, hidden) {
assert.equal(visibilityState, 'visible')
assert.equal(hidden, false)
done()
})
w.webContents.emit('-window-visibility-change', 'visible')
})
w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html')
})
}) })
describe('will-attach-webview event', () => { describe('will-attach-webview event', () => {