spec: Set node-integration in window.open should work

This commit is contained in:
Cheng Zhao 2015-09-09 16:11:45 +08:00
parent 446235c8cd
commit c2b2a2072f
2 changed files with 22 additions and 4 deletions

View file

@ -36,11 +36,20 @@ describe 'chromium feature', ->
describe 'window.open', ->
it 'returns a BrowserWindowProxy object', ->
b = window.open 'about:blank', 'test', 'show=no'
b = window.open 'about:blank', '', 'show=no'
assert.equal b.closed, false
assert.equal b.constructor.name, 'BrowserWindowProxy'
b.close()
it 'accepts "node-integration" as feature', (done) ->
listener = (event) ->
window.removeEventListener 'message', listener
b.close()
assert.equal event.data, 'undefined'
done()
window.addEventListener 'message', listener
b = window.open "file://#{fixtures}/pages/window-opener-node.html", '', 'node-integration=no,show=no'
describe 'window.opener', ->
ipc = remote.require 'ipc'
url = "file://#{fixtures}/pages/window-opener.html"
@ -58,19 +67,21 @@ describe 'chromium feature', ->
w.loadUrl url
it 'is not null for window opened by window.open', (done) ->
b = window.open url, 'test2', 'show=no'
b = window.open url, '', 'show=no'
ipc.on 'opener', (event, opener) ->
b.close()
done(if opener isnt null then undefined else opener)
describe 'window.opener.postMessage', ->
it 'sets source and origin correctly', (done) ->
b = window.open "file://#{fixtures}/pages/window-opener-postMessage.html", 'test', 'show=no'
window.addEventListener 'message', (event) ->
listener = (event) ->
window.removeEventListener 'message', listener
b.close()
assert.equal event.source.guestId, b.guestId
assert.equal event.origin, 'file://'
done()
window.addEventListener 'message', listener
b = window.open "file://#{fixtures}/pages/window-opener-postMessage.html", '', 'show=no'
describe 'creating a Uint8Array under browser side', ->
it 'does not crash', ->

View file

@ -0,0 +1,7 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
window.opener.postMessage(typeof process, '*')
</script>
</body>
</html>