webContents: providing dom-ready event
This commit is contained in:
parent
23afffa46d
commit
8c5f171a93
8 changed files with 52 additions and 0 deletions
|
@ -2,6 +2,8 @@ assert = require 'assert'
|
|||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
remote = require 'remote'
|
||||
http = require 'http'
|
||||
url = require 'url'
|
||||
|
||||
BrowserWindow = remote.require 'browser-window'
|
||||
|
||||
|
@ -222,3 +224,22 @@ describe 'browser-window module', ->
|
|||
assert.equal url, 'https://www.github.com/'
|
||||
done()
|
||||
w.loadUrl "file://#{fixtures}/pages/will-navigate.html"
|
||||
|
||||
describe 'dom-ready event', ->
|
||||
it 'emits when document is loaded', (done) ->
|
||||
server = http.createServer (req, res) ->
|
||||
action = url.parse(req.url, true).pathname
|
||||
if action == '/logo.png'
|
||||
img = fs.readFileSync(path.join(fixtures, 'assets', 'logo.png'))
|
||||
res.writeHead(200, {'Content-Type': 'image/png'})
|
||||
setTimeout ->
|
||||
res.end(img, 'binary')
|
||||
, 2000
|
||||
server.close()
|
||||
server.listen 62542, '127.0.0.1'
|
||||
remote.require('ipc').on 'dom-ready', (e, state) ->
|
||||
assert.equal state, 'interactive'
|
||||
done()
|
||||
w.webContents.on 'did-finish-load', ->
|
||||
w.close()
|
||||
w.loadUrl "file://#{fixtures}/pages/f.html"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue