Skip to content

Commit

Permalink
Add spec for webview visibility change on show
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinsawicki committed Jun 14, 2017
1 parent ce0684a commit f1a72ad
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions spec/webview-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,25 +1097,50 @@ describe('<webview> tag', function () {
})
})

it('inherits the parent window visibility state and receives visibilitychange events', function (done) {
w = new BrowserWindow({
show: false
describe('document.visibilityState/hidden', function () {
afterEach(function () {
ipcMain.removeAllListeners('pong')
})

ipcMain.once('pong', function (event, visibilityState, hidden) {
assert.equal(visibilityState, 'hidden')
assert.equal(hidden, true)
it('updates when the window is shown after the ready-to-show event', function (done) {
w = new BrowserWindow({
show: false
})

ipcMain.once('pong', function (event, visibilityState, hidden) {
assert.equal(visibilityState, 'visible')
assert.equal(hidden, false)
done()
w.once('ready-to-show', function () {
w.show()
})

ipcMain.on('pong', function (event, visibilityState, hidden) {
if (!hidden) {
assert.equal(visibilityState, 'visible')
done()
}
})

w.webContents.emit('-window-visibility-change', 'visible')
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', () => {
Expand Down

0 comments on commit f1a72ad

Please sign in to comment.