Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
We still need a document element when response body is empty.
Browse files Browse the repository at this point in the history
Updated changelog to reflect recent additions.
  • Loading branch information
assaf committed Jan 19, 2011
1 parent e2682e9 commit ffc09ac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,16 @@ zombie.js-changelog(7) -- Changelog
===================================


### Version 0.8.11 2011-01-19

Ensure fields are sent in the order they are described (José Valim).

Fix parsing of empty body (Vinicius Baggio).

267 Tests
3.8 sec to complete


### Version 0.8.10 2011-01-13

Allow setting cookies from subdomains (Damian Janowski & Michel Martens).
Expand Down
5 changes: 5 additions & 0 deletions spec/browser-spec.coffee
Expand Up @@ -74,6 +74,8 @@ brains.get "/dead", (req, res)-> res.send """
</html>
"""

brains.get "/empty", (req, res)-> res.send ""

brains.get "/soup", (req, res)-> res.send """
<h1>Tag soup</h1>
<p>One paragraph
Expand Down Expand Up @@ -138,6 +140,9 @@ vows.describe("Browser").addBatch(
"should pass single argument to callback": (args)-> assert.length args, 1
"should pass error to callback": (args)-> assert.ok args[0] instanceof Error
"should include status code in error": (args)-> assert.equal args[0].statusCode, 404
"empty page":
zombie.wants "http://localhost:3003/empty"
"should load document": (browser)-> assert.ok browser.body

"event emitter":
"successful":
Expand Down
6 changes: 0 additions & 6 deletions spec/history-spec.coffee
Expand Up @@ -8,8 +8,6 @@ brains.get "/boo", (req, res)->
res.send "<html><title>#{response}</title></html>"
brains.get "/redirect", (req, res)->
res.redirect "/boo?redirected=true"
brains.get "/empty", (req, res)->
res.send ""


vows.describe("History").addBatch(
Expand Down Expand Up @@ -156,10 +154,6 @@ vows.describe("History").addBatch(
"should include pathname": (location)-> assert.equal location.pathname, "/"
"should include search": (location)-> assert.equal location.search, ""
"should include hash": (location)-> assert.equal location.hash, ""
"empty":
zombie.wants "http://localhost:3003/empty"
"should load document": (browser)-> assert.equal browser.html(), ''


"redirect":
zombie.wants "http://localhost:3003/redirect"
Expand Down
3 changes: 2 additions & 1 deletion src/zombie/history.coffee
Expand Up @@ -163,11 +163,12 @@ class History
switch response.statusCode
when 200
browser.cookies(url.hostname, url.pathname).update response.headers["set-cookie"]
body = "<html></html>" if body.trim() == ""
document.open()
document.write body
document.close()

if document.documentElement or response.headers["content-length"] == '0'
if document.documentElement
browser.emit "loaded", browser
else
error = "Could not parse document at #{URL.format(url)}"
Expand Down

1 comment on commit ffc09ac

@vinibaggio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning it up!

Please sign in to comment.