spec: "new-window" event of BrowserWindow

This commit is contained in:
Cheng Zhao 2014-10-27 22:07:57 +08:00
parent 6f41598962
commit 64ce44d341

View file

@ -156,3 +156,20 @@ describe 'browser-window module', ->
w.on 'onbeforeunload', ->
done()
w.loadUrl 'file://' + path.join(fixtures, 'api', 'close-beforeunload-empty-string.html')
describe 'new-window event', ->
it 'emits when window.open is called', (done) ->
w.webContents.once 'new-window', (e, url, frameName) ->
e.preventDefault()
assert.equal url, 'http://host'
assert.equal frameName, 'host'
done()
w.loadUrl "file://#{fixtures}/pages/window-open.html"
it 'emits when link with target is called', (done) ->
w.webContents.once 'new-window', (e, url, frameName) ->
e.preventDefault()
assert.equal url, 'http://host/'
assert.equal frameName, 'target'
done()
w.loadUrl "file://#{fixtures}/pages/target-name.html"