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

Commit

Permalink
FIXED eliminated endless spinning of the event loop
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Nov 27, 2014
1 parent 8676317 commit d83c901
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Version 2.3.3 2014-11-27

FIXED eliminated endless spinning of the event loop

695 passing (10s)
8 pending


## Version 2.3.2 2014-11-26

FIXED XHR status and response text in case of error #811
Expand Down
10 changes: 4 additions & 6 deletions src/zombie/eventloop.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EventLoop extends EventEmitter
wait: (waitDuration, completionFunction)->
# Don't wait longer than duration
waitDuration = ms(waitDuration.toString()) || @browser.waitDuration
timeout = Date.now() + waitDuration
timeoutOn = Date.now() + waitDuration

# Someone (us) just started paying attention, start processing events
++@waiting
Expand All @@ -97,7 +97,7 @@ class EventLoop extends EventEmitter
timer = global.setTimeout(resolve, waitDuration)

ontick = (next)=>
if next >= timeout
if next >= timeoutOn
# Next event too long in the future, or no events in queue
# (Infinity), no point in waiting
resolve()
Expand Down Expand Up @@ -223,10 +223,8 @@ class EventLoop extends EventEmitter
@emit("tick", 0)
else
# All that's left are timers
time = @active._eventQueue.next()
@emit("tick", time)
#setTimeout @run.bind(this), time - Date.now()
@run()

This comment has been minimized.

Copy link
@yanovich

yanovich Nov 30, 2014

Contributor

Cool

nextTick = @active._eventQueue.next()
@emit("tick", nextTick)
catch error
@emit("error", error)
return
Expand Down
3 changes: 3 additions & 0 deletions test/history_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,13 @@ describe('History', function() {

describe('change hash', function() {
before(()=> browser.visit('/'));

before(function(done) {
browser.document.body.innerHTML = '<html><body>Wolf</body></html>';
browser.window.addEventListener('hashchange', ()=> done());
browser.window.location.hash = 'boo';
// Get the event loop running
browser.wait();
});

it('should add page to history', function() {
Expand Down

0 comments on commit d83c901

Please sign in to comment.