Permalink
Browse files

Methods like visit and fire no longer call wait if there's no callback.

  • Loading branch information...
1 parent a4ea2d8 commit ea15b26636837ac69584feb019b4ff9f6903b707 @assaf assaf committed Dec 19, 2011
Showing with 18 additions and 5 deletions.
  1. +11 −0 CHANGELOG.md
  2. +5 −3 lib/zombie/browser.coffee
  3. +2 −2 spec/eventloop_spec.coffee
View
@@ -1,6 +1,17 @@
zombie.js-changelog(7) -- Changelog
===================================
+
+## Version 0.12.7 2011-12-19
+
+Methods like `visit` and `fire` no longer call `wait` if there's no callback.
+
+The wait callback is called from `nextTick`. Fixes a possible race condition.
+
+ 366 Tests
+ 3.7 sec to complete
+
+
## Version 0.12.6 2011-12-18
You can now tell `browser.wait` when to complete processing events by passing either duration (in milliseconds) or a
@@ -389,10 +389,12 @@ class Browser extends EventEmitter
site = "http://#{site}" unless /^https?:/i.test(site)
url = URL.resolve(site, URL.parse(URL.format(url)))
@window.history._assign url
- @wait duration, (error, browser)=>
- reset_options()
- if callback
+ if callback
+ @wait duration, (error, browser)=>
+ reset_options()
callback error, browser, browser.statusCode, browser.errors
+ else
+ reset_options()
return
# ### browser.location => Location
@@ -60,9 +60,9 @@ Vows.describe("EventLoop").addBatch(
browser.window.setTimeout (-> @document.title += "1"), 100
browser.window.setTimeout (-> @document.title += "2"), 200
browser.window.setTimeout (-> @document.title += "3"), 300
- browser.wait 150, =>
+ browser.wait 100, =>
setTimeout =>
- browser.wait 150, @callback
+ browser.wait 100, @callback
, 300
"should not fire": (browser)->
assert.equal browser.document.title, "12"

0 comments on commit ea15b26

Please sign in to comment.