Skip to content

Commit

Permalink
Base support for forking a browser.
Browse files Browse the repository at this point in the history
Still need to add snapshooting the cookies, storage, cache and history.
  • Loading branch information
jadell committed Jan 28, 2011
1 parent 719fd7d commit c22994a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/browser-spec.coffee
Expand Up @@ -313,4 +313,24 @@ vows.describe("Browser").addBatch(
assert.match browser.document.title, /colorDepth=24/
assert.match browser.document.title, /pixelDepth=24/

"fork":
zombie.wants "http://localhost:3003/living"
"new browser":
topic: (browser)->
forked = browser.fork()
[forked, browser]
"should have two browser objects": (browsers)->
[forked, browser] = browsers
assert.isNotNull forked
assert.isNotNull browser
"should not be the same object": (browsers)->
[forked, browser] = browsers
assert.notStrictEqual browser, forked
"should navigate independently": (browsers)->
[forked, browser] = browsers
forked.visit "http://localhost:3003/dead"
forked.wait()
assert.equal browser.location.href, "http://localhost:3003/living#/"
assert.equal forked.location, "http://localhost:3003/dead"

).export(module)
10 changes: 10 additions & 0 deletions src/zombie/browser.coffee
Expand Up @@ -63,6 +63,16 @@ class Browser extends require("events").EventEmitter
else
throw "I don't recognize the option #{k}"

# Fork
# ----

# ### browser.fork() => Browser
#
# Return a new browser with a snapshot of this browser's data.
# Any changes to the forked browser's state do not affect this browser.
this.fork = ->
forked = new Browser()
return forked

# Windows
# -------
Expand Down

0 comments on commit c22994a

Please sign in to comment.