Permalink
Browse files

request/response events should not include target.

  • Loading branch information...
assaf committed Dec 5, 2012
1 parent 9292166 commit fb8d26a1f250e646687384dc4e40c7f5a1444e27
Showing with 10 additions and 12 deletions.
  1. +2 −2 lib/zombie/browser.coffee
  2. +2 −2 lib/zombie/resources.coffee
  3. +6 −8 test/browser_events_test.coffee
@@ -84,9 +84,9 @@ class Browser extends EventEmitter
# All the resources loaded by this browser.
@resources = new Resources(this)
- @on "request", (request, target)->
+ @on "request", (request)->
- @on "response", (request, response, target)->
+ @on "response", (request, response)->
browser.log "#{request.method} #{request.url} => #{response.statusCode}"
@on "redirect", (request, response)->
@@ -73,7 +73,7 @@ class Resources extends Array
request: request
target: options.target
@push(resource)
- @browser.emit("request", request, options.target)
+ @browser.emit("request", request)
@runFilters request, (error, response)=>
if error
@@ -88,7 +88,7 @@ class Resources extends Array
response.time = Date.now()
resource.response = response
- @browser.emit("response", request, response, options.target)
+ @browser.emit("response", request, response)
callback(null, resource.response)
return
@@ -48,19 +48,18 @@ describe "Browser events", ->
brains.get "/browser-events/redirected", (req, res)->
res.send "Very well then"
- browser.on "request", (request, target)->
- events.resource.push([request, target])
+ browser.on "request", (request)->
+ events.resource.push([request])
browser.on "redirect", (request, response)->
events.resource.push([request, response])
- browser.on "response", (request, response, target)->
- events.resource.push([request, response, target])
+ browser.on "response", (request, response)->
+ events.resource.push([request, response])
browser.visit "/browser-events/resource", done
it "should receive resource requests", ->
- [request, target] = events.resource[0]
+ [request] = events.resource[0]
assert.equal request.url, "http://localhost:3003/browser-events/resource"
- assert target instanceof HTML.HTMLDocument
it "should receive resource redirects", ->
[request, response] = events.resource[1]
@@ -69,11 +68,10 @@ describe "Browser events", ->
assert.equal response.url, "http://localhost:3003/browser-events/redirected"
it "should receive resource responses", ->
- [request, response, target] = events.resource[2]
+ [request, response] = events.resource[2]
assert.equal request.url, "http://localhost:3003/browser-events/resource"
assert.equal response.statusCode, 200
assert.equal response.redirects, 1
- assert target instanceof HTML.HTMLDocument
describe "opening a window", ->

0 comments on commit fb8d26a

Please sign in to comment.