Skip to content

Instantly share code, notes, and snippets.

@seriallos
Created April 14, 2013 18:53
Show Gist options
  • Save seriallos/5383782 to your computer and use it in GitHub Desktop.
Save seriallos/5383782 to your computer and use it in GitHub Desktop.
ZombieJS Event Behavior Questions
$ coffee zombie-test.coffee
:: REQUEST ::
requesting http://google.com/
:: REDIRECT ::
req.time = 1365965486011
res.time = undefined
time to redirect = NaN ms
redirecting to http://www.google.com/
:: RESPONSE ::
response = 292 ms
total time = 291
done
Browser = require 'zombie2'
b = new Browser()
b.features = 'no-scripts no-css'
requestStart = null
b.on 'request', ( req ) ->
console.log ":: REQUEST ::"
requestStart = Date.now()
console.log 'requesting ' + req.url
b.on 'redirect', ( req, res ) ->
console.log ":: REDIRECT ::"
resTime = res.time - req.time
console.log "req.time = #{req.time}"
console.log "res.time = #{res.time}"
console.log "time to redirect = #{resTime} ms"
console.log 'redirecting to ' + res.url
b.on 'response', ( req, res ) ->
console.log ":: RESPONSE ::"
totalTime = Date.now() - requestStart
resTime = res.time - req.time
console.log "response = #{resTime} ms"
console.log "total time = #{totalTime}"
b.visit 'http://google.com/', () ->
console.log 'done'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment