describe 'dom-ready event', ->
it 'emits when document is loaded', (done) ->
+ ipc = remote.require 'ipc'
server = http.createServer (req, res) ->
action = url.parse(req.url, true).pathname
if action == '/logo.png'
, 2000
server.close()
server.listen 62542, '127.0.0.1'
- remote.require('ipc').on 'dom-ready', (e, state) ->
+ ipc.on 'dom-ready', (e, state) ->
+ ipc.removeAllListeners 'dom-ready'
assert.equal state, 'interactive'
done()
w.webContents.on 'did-finish-load', ->
describe '<webview>.reload()', ->
it 'should emit beforeunload handler', (done) ->
- webview.addEventListener 'did-finish-load', (e) ->
- webview.reload()
listener = (e) ->
assert.equal e.channel, 'onbeforeunload'
webview.removeEventListener 'ipc-message', listener
done()
- webview.addEventListener 'console-message', (e) ->
- console.log(e)
+ listener2 = (e) ->
+ webview.reload()
+ webview.removeEventListener 'did-finish-load', listener2
webview.addEventListener 'ipc-message', listener
+ webview.addEventListener 'did-finish-load', listener2
webview.setAttribute 'nodeintegration', 'on'
webview.src = "file://#{fixtures}/pages/beforeunload-false.html"
document.body.appendChild webview