Merge pull request #3670 from mixmaxhq/jeff/fix_window_open

Fix `window.open` not respecting the features string
This commit is contained in:
Cheng Zhao 2015-12-04 10:55:51 +08:00
Родитель f6dbc3001e 225fe72d03
Коммит 504d3d3088
3 изменённых файлов: 13 добавлений и 4 удалений

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

@ -5,7 +5,7 @@ frameToGuest = {}
# Copy attribute of |parent| to |child| if it is not defined in |child|.
mergeOptions = (child, parent) ->
for own key, value of parent when key not in child
for own key, value of parent when key not in Object.keys child
if typeof value is 'object'
child[key] = mergeOptions {}, value
else

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

@ -75,13 +75,22 @@ describe 'chromium feature', ->
it 'inherit options of parent window', (done) ->
listener = (event) ->
size = remote.getCurrentWindow().getSize()
assert.equal event.data, "size: #{size.width} #{size.height}"
[width, height] = remote.getCurrentWindow().getSize()
assert.equal event.data, "size: #{width} #{height}"
b.close()
done()
window.addEventListener 'message', listener
b = window.open "file://#{fixtures}/pages/window-open-size.html", '', 'show=no'
it 'does not override child options', (done) ->
size = {width: 350, height: 450}
listener = (event) ->
assert.equal event.data, "size: #{size.width} #{size.height}"
b.close()
done()
window.addEventListener 'message', listener
b = window.open "file://#{fixtures}/pages/window-open-size.html", '', "show=no,width=#{size.width},height=#{size.height}"
describe 'window.opener', ->
@timeout 10000

2
spec/fixtures/pages/window-open-size.html поставляемый
Просмотреть файл

@ -2,7 +2,7 @@
<body>
<script type="text/javascript" charset="utf-8">
var size = require('electron').remote.getCurrentWindow().getSize();
window.opener.postMessage('size: ' + size.width + ' ' + size.height, '*')
window.opener.postMessage('size: ' + size[0] + ' ' + size[1], '*')
</script>
</body>
</html>