Created
April 14, 2013 18:53
-
-
Save seriallos/5383782 to your computer and use it in GitHub Desktop.
ZombieJS Event Behavior Questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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