spec: Fix error when refreshing

This commit is contained in:
Cheng Zhao 2015-05-04 12:51:28 +08:00
parent 0d4d2080ca
commit a04222f398
2 changed files with 7 additions and 5 deletions

View file

@ -227,6 +227,7 @@ describe 'browser-window module', ->
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'
@ -237,7 +238,8 @@ describe 'browser-window module', ->
, 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', ->

View file

@ -181,15 +181,15 @@ describe '<webview> tag', ->
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