Merge pull request #2879 from deepak1556/web_contents_visibility_patch
browser: notify webcontents hidden when window not shown
This commit is contained in:
commit
10731de9d6
3 changed files with 30 additions and 1 deletions
|
@ -159,8 +159,13 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||||
// Then show it.
|
// Then show it.
|
||||||
bool show = true;
|
bool show = true;
|
||||||
options.Get(switches::kShow, &show);
|
options.Get(switches::kShow, &show);
|
||||||
if (show)
|
if (show) {
|
||||||
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) {
|
void NativeWindow::SetSize(const gfx::Size& size) {
|
||||||
|
|
|
@ -23,6 +23,23 @@ describe 'chromium feature', ->
|
||||||
{port} = server.address()
|
{port} = server.address()
|
||||||
$.get "http://127.0.0.1:#{port}"
|
$.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', ->
|
describe 'navigator.webkitGetUserMedia', ->
|
||||||
it 'calls its callbacks', (done) ->
|
it 'calls its callbacks', (done) ->
|
||||||
@timeout 5000
|
@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…
Add table
Reference in a new issue