diff --git a/spec/fixtures/pages/visibilitychange.html b/spec/fixtures/pages/visibilitychange.html new file mode 100644 index 00000000000..9f49f520de1 --- /dev/null +++ b/spec/fixtures/pages/visibilitychange.html @@ -0,0 +1,11 @@ + + + + + diff --git a/spec/fixtures/pages/webview-visibilitychange.html b/spec/fixtures/pages/webview-visibilitychange.html new file mode 100644 index 00000000000..b0f05056382 --- /dev/null +++ b/spec/fixtures/pages/webview-visibilitychange.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 8a109b6d7bf..754321c7454 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -867,4 +867,25 @@ describe(' 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') + }) })