Permalink
Browse files

Merge remote-tracking branch 'nauhygon/master'

Conflicts:
	spec/forms_spec.coffee
  • Loading branch information...
2 parents df80931 + 770cd61 commit 6cd881704c31e0b3a79fa4ac0ebd0c41193dcff1 @zzen committed Mar 8, 2012
Showing with 599 additions and 594 deletions.
  1. +7 −1 lib/zombie/browser.coffee
  2. +4 −1 lib/zombie/cookies.coffee
  3. +1 −0 lib/zombie/resources.coffee
  4. +25 −3 spec/cookie_spec.coffee
  5. +562 −589 spec/forms_spec.coffee
@@ -20,7 +20,7 @@ WebSocket = require("./websocket")
HTML = JSDom.dom.level3.html
MOUSE_EVENT_NAMES = ["mousedown", "mousemove", "mouseup"]
-BROWSER_OPTIONS = ["credentials", "debug", "htmlParser", "loadCSS", "referer", "runScripts", "silent", "site", "userAgent", "waitFor"]
+BROWSER_OPTIONS = ["acceptEncoding", "credentials", "debug", "htmlParser", "loadCSS", "referer", "runScripts", "silent", "site", "userAgent", "waitFor"]
PACKAGE = JSON.parse(require("fs").readFileSync(__dirname + "/../../package.json"))
@@ -52,6 +52,9 @@ class Browser extends EventEmitter
# -------
+ # Supported compression schema names (called content-coding tokens), separated by commas.
+ @acceptEncoding = "identity"
+
# Object containing authorization credentials. Supported schemes include
# `basic` (HTTP Basic), `oauth` (OAuth 2.0 draft 10) and `bearer` (OAuth
# 2.0 draft 20). Scheme name is case insensitive.
@@ -576,6 +579,9 @@ class Browser extends EventEmitter
for option in field.options
if option.label == value
return option
+ for option in field.options
+ if option.textContent.replace(/^\s+|\s+$/g, '') == value
+ return option
throw new Error("No OPTION '#{value}'")
else
throw new Error("No SELECT matching '#{selector}'")
@@ -41,8 +41,11 @@ dequote = (value)->
# Determines if domain matches hostname.
domainMatch = (domain, hostname)->
+ if domain.charAt(0) == '.'
+ domain = domain.substring(1)
+ i = hostname.length - domain.length
return domain == hostname ||
- (domain.charAt(0) == "." && domain.substring(1) == hostname.replace(/^[^.]+\./, ""))
+ (i > 0 && hostname[i-1] == '.' && domain == hostname.substring(i))
# Domain/path specific scope around the global cookies collection.
@@ -166,6 +166,7 @@ class Resources extends Array
# Clone headers before we go and modify them.
headers = if headers then JSON.parse(JSON.stringify(headers)) else {}
+ headers["Accept-Encoding"] = @_browser.acceptEncoding
headers["User-Agent"] = @_browser.userAgent
if method == "GET" || method == "HEAD"
# Request paramters go in query string
View
@@ -55,11 +55,33 @@ Vows.describe("Cookies").addBatch(
assert.isUndefined cookies.get("_domain2")
assert.isUndefined cookies.get("_domain3")
- "host in domain":
+ "same domain (.localhost)":
+ topic: (browser)->
+ browser.cookies(".localhost")
+ "should have access to domain cookies": (cookies)->
+ assert.equal cookies.get("_name"), "value"
+ "should have access to .host cookies": (cookies)->
+ assert.equal cookies.get("_domain1"), "here"
+ "should not have access to other hosts' cookies": (cookies)->
+ assert.isUndefined cookies.get("_domain2")
+ assert.isUndefined cookies.get("_domain3")
+
+ "subdomain (host.localhost)":
topic: (browser)->
browser.cookies("host.localhost")
- "should not have access to domain cookies": (cookies)->
- assert.isUndefined cookies.get("_name")
+ "should have access to domain cookies": (cookies)->
+ assert.equal cookies.get("_name"), "value"
+ "should have access to .host cookies": (cookies)->
+ assert.equal cookies.get("_domain1"), "here"
+ "should not have access to other hosts' cookies": (cookies)->
+ assert.isUndefined cookies.get("_domain2")
+ assert.isUndefined cookies.get("_domain3")
+
+ "subdomain in subdomain (subdomain.host.localhost)":
+ topic: (browser)->
+ browser.cookies("subdomain.host.localhost")
+ "should have access to domain cookies": (cookies)->
+ assert.equal cookies.get("_name"), "value"
"should have access to .host cookies": (cookies)->
assert.equal cookies.get("_domain1"), "here"
"should not have access to other hosts' cookies": (cookies)->
Oops, something went wrong.

0 comments on commit 6cd8817

Please sign in to comment.