browser: hide webcontents when window not shown
This commit is contained in:
parent
1520ebfe1f
commit
5ca5c4fb92
3 changed files with 30 additions and 1 deletions
|
@ -159,8 +159,13 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
|||
// Then show it.
|
||||
bool show = true;
|
||||
options.Get(switches::kShow, &show);
|
||||
if (show)
|
||||
if (show) {
|
||||
Show();
|
||||
} else {
|
||||
// When RenderView is created it sets to visible, this is to prevent
|
||||
// breaking the visibility API.
|
||||
web_contents()->WasHidden();
|
||||
}
|
||||
}
|
||||
|
||||
void NativeWindow::SetSize(const gfx::Size& size) {
|
||||
|
|
|
@ -23,6 +23,23 @@ describe 'chromium feature', ->
|
|||
{port} = server.address()
|
||||
$.get "http://127.0.0.1:#{port}"
|
||||
|
||||
describe 'document.hidden', ->
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
ipc = remote.require 'ipc'
|
||||
url = "file://#{fixtures}/pages/document-hidden.html"
|
||||
w = null
|
||||
|
||||
afterEach ->
|
||||
w?.destroy()
|
||||
ipc.removeAllListeners 'hidden'
|
||||
|
||||
it 'is set correctly when window is not shown', (done) ->
|
||||
ipc.once 'hidden', (event, hidden) ->
|
||||
assert hidden
|
||||
done()
|
||||
w = new BrowserWindow(show:false)
|
||||
w.loadUrl url
|
||||
|
||||
describe 'navigator.webkitGetUserMedia', ->
|
||||
it 'calls its callbacks', (done) ->
|
||||
@timeout 5000
|
||||
|
|
7
spec/fixtures/pages/document-hidden.html
vendored
Normal file
7
spec/fixtures/pages/document-hidden.html
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
require('ipc').send('hidden', document.hidden);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue