Jump To …

eventloop.coffee

An event loop. Allows us to block waiting for asynchronous events (timers, XHR, script loading, etc). This is abstracted in the API as browser.wait.

Handles the Window event loop, timers and pending requests.

undefined

Size of processing queue (number of ongoing tasks).

undefined

Requests on wait that cannot be handled yet: there's no event in the queue, but we anticipate one (in-progress XHR request).

undefined

Reset the event loop (clearning any timers, etc) before using a new window.

undefined

Prevent any existing timers from firing.

undefined

Add event-loop features to window (mainly timers).

undefined

Remove timer.

undefined

Add new timeout. If the timeout is short enough, we ask wait to automatically wait for it to fire, by storing the time in timer.next. We need to clear next after the timer fires or when cancelled.

undefined

Resume timer: when created, and when entering browser.wait again.

undefined

Something weird happens if we use setTimeout(fn, 0), seems that the timer never fires

undefined

Pause timer when leaving browser.wait. Reset remaining delay so we start fresh on next browser.wait.

undefined

Add timer and start the clock.

undefined

Pause timer when leaving browser.wait. Reset remaining delay so we

undefined

Add timer and start the clock.

undefined

perform(fn)

Run the function as part of the event queue (calls to wait will wait for this function to complete). Function can be anything and is called synchronous with a done function; when it's done processing, it lets the event loop know by calling the done function.

undefined

Dispatch event asynchronously, wait for it to complete. Returns true if preventDefault was set.

undefined

Process all events from the queue. This method returns immediately, events are processed in the background. When all events are exhausted, it calls the callback.

This method will wait for any resources to load (XHR, script elements, iframes, etc). DOM events are handled synchronously, so will also wait for them.

Duration is either how long to wait, or a function evaluated against the window that returns true when done. The default duration is browser.waitFor.

undefined

Called once at the end of the loop. Also, set to null when done, since waiting may be called multiple times.

undefined

Mark as done so we don't run it again.

undefined

Remove from waiting list, pause timers if last waiting.

undefined

Callback and event emitter, pick your poison.

undefined

don't block forever

undefined

Duration is a function, proceed until function returns false.

undefined

May be called multiple times from nextTick

undefined

Processing XHR/JS events, keep waiting.

undefined

not done and no events, so wait for the next timer.

undefined

if there are no timers, next is infinity, larger then done_at, no waiting

undefined

No one is waiting, resume firing timers.

undefined

Pause any timers from firing while we're not listening.

undefined

Resumes any timers.

undefined

Note: timer.resume modifies _timers

undefined