You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
e2e-istanbul/node_modules/selenium-webdriver/docs/class_webdriver_promise_Con...

117 lines
38 KiB

<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>webdriver.promise.ControlFlow</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Class webdriver.promise.ControlFlow</h1><a class="source" href="source/lib/webdriver/promise.js.src.html#l943">code &raquo;</a><pre><code><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a>
&#x2514; webdriver.promise.ControlFlow</code></pre></header><section><p>Handles the execution of scheduled tasks, each of which may be an
asynchronous operation. The control flow will ensure tasks are executed in
the ordered scheduled, starting each task only once those before it have
completed.
<p>Each task scheduled within this flow may return a
<code class="type"><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code> to indicate it is an asynchronous
operation. The ControlFlow will wait for such promises to be resolved before
marking the task as completed.
<p>Tasks and each callback registered on a <code class="type"><a href="class_webdriver_promise_Deferred.html">webdriver.promise.Deferred</a></code>
will be run in their own ControlFlow frame. Any tasks scheduled within a
frame will have priority over previously scheduled tasks. Furthermore, if
any of the tasks in the frame fails, the remainder of the tasks in that frame
will be discarded and the failure will be propagated to the user through the
callback/task's promised result.
<p>Each time a ControlFlow empties its task queue, it will fire an
<code class="type"><a href="enum_webdriver_promise_ControlFlow_EventType.html#webdriver.promise.ControlFlow.EventType.IDLE">webdriver.promise.ControlFlow.EventType.IDLE</a></code> event. Conversely,
whenever the flow terminates due to an unhandled error, it will remove all
remaining tasks in its queue and fire an
<code class="type"><a href="enum_webdriver_promise_ControlFlow_EventType.html#webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION">webdriver.promise.ControlFlow.EventType.UNCAUGHT_EXCEPTION</a></code> event. If
there are no listeners registered with the flow, the error will be
rethrown to the global error handler.<h2>Constructor</h2><div class="ctor wrap-details public"><div><div class="ctor"><span class="member">webdriver.promise.ControlFlow <span class="args">( opt_timer )</span></span></div><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_timer: <code class="type"><a href="class_webdriver_promise_ControlFlow.html#webdriver.promise.ControlFlow.Timer">webdriver.promise.ControlFlow.Timer</a>=</code><dd>The timer object
to use. Should only be set for testing.</dl></table></div></div></div></section><section><h2>Enumerations</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="enum_webdriver_promise_ControlFlow_EventType.html">webdriver.promise.ControlFlow.EventType</a><dd>Events that may be emitted by an <code class="type"><a href="class_webdriver_promise_ControlFlow.html">webdriver.promise.ControlFlow</a></code>.</dl></table></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="typedefs"><h2>Type Definitions</h2><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l970">code &raquo;</a><a class="member" name="webdriver.promise.ControlFlow.Timer">webdriver.promise.ControlFlow.Timer</a> : <code class="type">{clearInterval: function(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>), clearTimeout: function(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>), setInterval: function(!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, setTimeout: function(!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>, <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>}</code></div><div>No description.</div></summary></details></div></div></section><section id="instance-methods"><h2>Instance Methods</h2><h3>Defined in <code class="type">webdriver.promise.ControlFlow</code></h3><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1476">code &raquo;</a><span class="member"><a name="abortFrame_">abortFrame_</a> <span class="args">( error )</span></span></div><p>Aborts the current frame. The frame, and all of the tasks scheduled within it
will be discarded. If this instance does not have an active frame, it will
immediately terminate all execution.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>error: <code class="type">*</code><dd>The reason the frame is being aborted; typically either
an Error or string.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1634">code &raquo;</a><span class="member"><a name="abortNow_">abortNow_</a> <span class="args">( error )</span></span></div><p>Aborts this flow, abandoning all remaining tasks. If there are
listeners registered, an <code >UNCAUGHT_EXCEPTION</code> will be emitted with the
offending <code >error</code>, otherwise, the <code >error</code> will be rethrown to the
global error handler.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>error: <code class="type">*</code><dd>Object describing the error that caused the flow to
abort; usually either an Error or string value.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1185">code &raquo;</a><span class="member"><a name="annotateError">annotateError</a> <span class="args">( e )</span> &rArr; <code class="type">!(<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error">Error</a>|goog.testing.JsUnitException)</code></span></div><p>Appends a summary of this instance's recent task history to the given
error's stack trace. This function will also ensure the error's stack trace
is in canonical form.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>e: <code class="type">!(<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error">Error</a>|goog.testing.JsUnitException)</code><dd>The error to annotate.</dl><tr><th>Returns<tr><td><dl>The annotated error.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1329">code &raquo;</a><span class="member"><a name="await">await</a> <span class="args">( promise )</span> &rArr; <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Schedules a task that will wait for another promise to resolve. The resolved
promise's value will be returned as the task result.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>promise: <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code><dd>The promise to wait on.</dl><tr><th>Returns<tr><td><dl>A promise that will resolve when the
task has completed.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1353">code &raquo;</a><span class="member"><a name="cancelEventLoop_">cancelEventLoop_</a> <span class="args">( )</span></span></div><p>Cancels the event loop, if necessary.</summary></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1617">code &raquo;</a><span class="member"><a name="cancelShutdown_">cancelShutdown_</a> <span class="args">( )</span></span></div><p>Cancels the shutdown sequence if it is currently scheduled.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1147">code &raquo;</a><span class="member"><a name="clearHistory">clearHistory</a> <span class="args">( )</span></span></div><p>Clears this instance's task history.</summary></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1594">code &raquo;</a><span class="member"><a name="commenceShutdown_">commenceShutdown_</a> <span class="args">( )</span></span></div><p>Commences the shutdown sequence for this instance. After one turn of the
event loop, this object will emit the
<code class="type"><a href="enum_webdriver_promise_ControlFlow_EventType.html#webdriver.promise.ControlFlow.EventType.IDLE">webdriver.promise.ControlFlow.EventType.IDLE</a></code> event to signal
listeners that it has completed. During this wait, if another task is
scheduled, the shutdown will be aborted.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1227">code &raquo;</a><code class="type">&lt;T&gt;</code> <span class="member"><a name="execute">execute</a> <span class="args">( fn, opt_description )</span> &rArr; <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.&lt;T&gt;</code></span></div><p>Schedules a task for execution. If there is nothing currently in the
queue, the task will be executed in the next turn of the event loop.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>fn: <code class="type">function(): (T|<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a>.&lt;T&gt;)</code><dd>The function to
call to start the task. If the function returns a
<code class="type"><a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code>, this instance will wait for it to be
resolved before starting the next task.<dt>opt_description: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>A description of the task.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved
with the result of the action.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1126">code &raquo;</a><span class="member"><a name="getHistory">getHistory</a> <span class="args">( )</span> &rArr; <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a>.&lt;<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>&gt;</code></span></div><p>Returns a summary of the recent task activity for this instance. This
includes the most recently completed task, as well as any parent tasks. In
the returned summary, the task at index N is considered a sub-task of the
task at index N+1.</summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>A summary of this instance's recent task
activity.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1425">code &raquo;</a><span class="member"><a name="getNextTask_">getNextTask_</a> <span class="args">( )</span> &rArr; <code class="type"><a href="class_webdriver_promise_Task_.html">webdriver.promise.Task_</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The next task to execute, or
<code >null</code> if a frame was resolved.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1209">code &raquo;</a><span class="member"><a name="getSchedule">getSchedule</a> <span class="args">( )</span> &rArr; <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div></summary><div class="info"><table><tbody><tr><th>Returns<tr><td><dl>The scheduled tasks still pending with this instance.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1109">code &raquo;</a><span class="member"><a name="reset">reset</a> <span class="args">( )</span></span></div><p>Resets this instance, clearing its queue and removing all event listeners.</summary></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1448">code &raquo;</a><span class="member"><a name="resolveFrame_">resolveFrame_</a> <span class="args">( frame )</span></span></div></summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>frame: <code class="type">!<a href="class_webdriver_promise_Frame_.html">webdriver.promise.Frame_</a></code><dd>The frame to resolve.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1368">code &raquo;</a><span class="member"><a name="runEventLoop_">runEventLoop_</a> <span class="args">( )</span></span></div><p>Executes the next task for the current frame. If the current frame has no
more tasks, the frame's result will be resolved, returning control to the
frame's creator. This will terminate the flow if the completed frame was at
the top of the stack.</summary></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1517">code &raquo;</a><span class="member"><a name="runInNewFrame_">runInNewFrame_</a> <span class="args">( fn, callback, errback, opt_activate )</span></span></div><p>Executes a function in a new frame. If the function does not schedule any new
tasks, the frame will be discarded and the function's result returned
immediately. Otherwise, a promise will be returned. This promise will be
resolved with the function's result once all of the tasks scheduled within
the function have been completed. If the function's frame is aborted, the
returned promise will be rejected.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>fn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to execute.<dt>callback: <code class="type">function(*)</code><dd>The function to call with a successful result.<dt>errback: <code class="type">function(*)</code><dd>The function to call if there is an error.<dt>opt_activate: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>=</code><dd>Whether the active frame should be updated to
the newly created frame so tasks are treated as sub-tasks.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1340">code &raquo;</a><span class="member"><a name="scheduleEventLoopStart_">scheduleEventLoopStart_</a> <span class="args">( )</span></span></div><p>Schedules the interval for this instance's event loop, if necessary.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1259">code &raquo;</a><span class="member"><a name="timeout">timeout</a> <span class="args">( ms, opt_description )</span> &rArr; <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Inserts a <code >setTimeout</code> into the command queue. This is equivalent to
a thread sleep in a synchronous programming language.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>ms: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The timeout delay, in milliseconds.<dt>opt_description: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>A description to accompany the timeout.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved with
the result of the action.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1157">code &raquo;</a><span class="member"><a name="trimHistory_">trimHistory_</a> <span class="args">( )</span></span></div><p>Removes a completed task from this instance's history record. If any
tasks remain from aborted frames, those will be removed as well.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1291">code &raquo;</a><span class="member"><a name="wait">wait</a> <span class="args">( condition, timeout, opt_message )</span> &rArr; <code class="type">!<a href="class_webdriver_promise_Promise.html">webdriver.promise.Promise</a></code></span></div><p>Schedules a task that shall wait for a condition to hold. Each condition
function may return any value, but it will always be evaluated as a boolean.
<p>Condition functions may schedule sub-tasks with this instance, however,
their execution time will be factored into whether a wait has timed out.
<p>In the event a condition returns a Promise, the polling loop will wait for
it to be resolved before evaluating whether the condition has been satisfied.
The resolution time for a promise is factored into whether a wait has timed
out.
<p>If the condition function throws, or returns a rejected promise, the
wait task will fail.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>condition: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The condition function to poll.<dt>timeout: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>How long to wait, in milliseconds, for the condition
to hold before timing out.<dt>opt_message: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>An optional error message to include if the
wait times out; defaults to the empty string.</dl><tr><th>Returns<tr><td><dl>A promise that will be resolved when the
condition has been satisified. The promise shall be rejected if the wait
times out waiting for the condition.</dl></table></div></details></div></div><h3>Defined in <code class="type"><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></h3><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l116">code &raquo;</a><span class="member"><a name="addListener">addListener</a> <span class="args">( type, listenerFn, opt_scope )</span> &rArr; <code class="type">!<a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></span></div><p>Registers a listener.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to listen for.<dt>listenerFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to invoke when the event is fired.<dt>opt_scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd>The object in whose scope to invoke the listener.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details private"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l90">code &raquo;</a><span class="member"><a name="addListener_">addListener_</a> <span class="args">( type, listenerFn, opt_scope, opt_oneshot )</span> &rArr; <code class="type">!<a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></span></div><p>Registers a listener.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to listen for.<dt>listenerFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to invoke when the event is fired.<dt>opt_scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd>The object in whose scope to invoke the listener.<dt>opt_oneshot: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a>=</code><dd>Whether the listener should be removed after
the first event is fired.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l44">code &raquo;</a><span class="member"><a name="emit">emit</a> <span class="args">( type, var_args )</span></span></div><p>Fires an event and calls all listeners.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to emit.<dt>var_args: <code class="type">...*</code><dd>Any arguments to pass to each listener.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l71">code &raquo;</a><span class="member"><a name="listeners">listeners</a> <span class="args">( type )</span> &rArr; <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>Returns a mutable list of listeners for a specific type of event.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to retrieve the listeners for.</dl><tr><th>Returns<tr><td><dl>The registered listeners for
the given event type.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l142">code &raquo;</a><span class="member"><a name="on">on</a> <span class="args">( type, listenerFn, opt_scope )</span> &rArr; <code class="type">!<a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></span></div><p>An alias for <code >#addListener()</code>.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to listen for.<dt>listenerFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to invoke when the event is fired.<dt>opt_scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd>The object in whose scope to invoke the listener.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l130">code &raquo;</a><span class="member"><a name="once">once</a> <span class="args">( type, listenerFn, opt_scope )</span> &rArr; <code class="type">!<a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></span></div><p>Registers a one-time listener which will be called only the first time an
event is emitted, after which it will be removed.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to listen for.<dt>listenerFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to invoke when the event is fired.<dt>opt_scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>=</code><dd>The object in whose scope to invoke the listener.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l173">code &raquo;</a><span class="member"><a name="removeAllListeners">removeAllListeners</a> <span class="args">( opt_type )</span> &rArr; <code class="type">!<a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></span></div><p>Removes all listeners for a specific type of event. If no event is
specified, all listeners across all types will be removed.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The type of event to remove listeners from.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l152">code &raquo;</a><span class="member"><a name="removeListener">removeListener</a> <span class="args">( type, listenerFn )</span> &rArr; <code class="type">!<a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></span></div><p>Removes a previously registered event listener.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>type: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The type of event to unregister.<dt>listenerFn: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The handler function to remove.</dl><tr><th>Returns<tr><td><dl>A self reference.</dl></table></div></details></div></div></section><section id="instance-properties"><h2>Instance Properties</h2><h3>Defined in <code class="type">webdriver.promise.ControlFlow</code></h3><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1036">code &raquo;</a><span class="member"><a name="activeFrame_">activeFrame_</a> : <code class="type"><a href="class_webdriver_promise_Frame_.html">webdriver.promise.Frame_</a></code></span></div><p>Tracks the active execution frame for this instance. Lazily initialized
when the first task is scheduled.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1076">code &raquo;</a><span class="member"><a name="eventLoopId_">eventLoopId_</a> : <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Interval ID for this instance's event loop.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l959">code &raquo;</a><span class="member"><a name="history_">history_</a> : <code class="type">!<a href="http://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></code></span></div><p>A list of recent tasks. Each time a new task is started, or a frame is
completed, the previously recorded task is removed from this list. If
there are multiple tasks, task N+1 is considered a sub-task of task
N.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1103">code &raquo;</a><span class="member"><a name="numAbortedFrames_">numAbortedFrames_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>The number of aborted frames since the last time a task was executed or a
frame completed successfully.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1095">code &raquo;</a><span class="member"><a name="pendingRejections_">pendingRejections_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>The number of "pending" promise rejections.
<p>Each time a promise is rejected and is not handled by a listener, it will
schedule a 0-based timeout to check if it is still unrejected in the next
turn of the JS-event loop. This allows listeners to attach to, and handle,
the rejected promise at any point in same turn of the event loop that the
promise was rejected.
<p>When this flow's own event loop triggers, it will not run if there
are any outstanding promise rejections. This allows unhandled promises to
be reported before a new task is started, ensuring the error is reported to
the current task queue.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1048">code &raquo;</a><span class="member"><a name="schedulingFrame_">schedulingFrame_</a> : <code class="type"><a href="class_webdriver_promise_Frame_.html">webdriver.promise.Frame_</a></code></span></div><p>A reference to the frame in which new tasks should be scheduled. If
<code >null</code>, tasks will be scheduled within the active frame. When forcing
a function to run in the context of a new frame, this pointer is used to
ensure tasks are scheduled within the newly created frame, even though it
won't be active yet.</summary></details></div></div><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1069">code &raquo;</a><span class="member"><a name="shutdownId_">shutdownId_</a> : <code class="type">?<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>Timeout ID set when the flow is about to shutdown without any errors
being detected. Upon shutting down, the flow will emit an
<code class="type"><a href="enum_webdriver_promise_ControlFlow_EventType.html#webdriver.promise.ControlFlow.EventType.IDLE">webdriver.promise.ControlFlow.EventType.IDLE</a></code> event. Idle events
always follow a brief timeout in order to catch latent errors from the last
completed task. If this task had a callback registered, but no errback, and
the task fails, the unhandled failure would not be reported by the promise
system until the next turn of the event loop:
// Schedule 1 task that fails.
var result = webriver.promise.controlFlow().schedule('example',
function() { return webdriver.promise.rejected('failed'); });
// Set a callback on the result. This delays reporting the unhandled
// failure for 1 turn of the event loop.
result.then(goog.nullFunction);</summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l950">code &raquo;</a><span class="member"><a name="timer">timer</a> : <code class="type"><a href="class_webdriver_promise_ControlFlow.html#webdriver.promise.ControlFlow.Timer">webdriver.promise.ControlFlow.Timer</a></code></span></div><p>The timer used by this instance.</summary></details></div></div><h3>Defined in <code class="type"><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter</a></code></h3><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/events.js.src.html#l35">code &raquo;</a><span class="member"><a name="events_">events_</a> : <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code></span></div><p>Map of events to registered listeners.</summary></details></div></div></section><section id="static-properties"><h2>Static Properties</h2><div class="wrap-details private"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1174">code &raquo;</a><span class="member"><a name="webdriver.promise.ControlFlow.ANNOTATION_PROPERTY_">webdriver.promise.ControlFlow.ANNOTATION_PROPERTY_</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></span></div><p>Property used to track whether an error has been annotated by
<code class="type"><a href="class_webdriver_promise_ControlFlow.html#annotateError">webdriver.promise.ControlFlow#annotateError</a></code>.</summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l1028">code &raquo;</a><span class="member"><a name="webdriver.promise.ControlFlow.EVENT_LOOP_FREQUENCY">webdriver.promise.ControlFlow.EVENT_LOOP_FREQUENCY</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code></span></div><p>How often, in milliseconds, the event loop should run.</summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l977">code &raquo;</a><span class="member"><a name="webdriver.promise.ControlFlow.defaultTimer">webdriver.promise.ControlFlow.defaultTimer</a> : <code class="type"><a href="class_webdriver_promise_ControlFlow.html#webdriver.promise.ControlFlow.Timer">webdriver.promise.ControlFlow.Timer</a></code></span></div><p>The default timer object, which uses the global timer functions.</summary></details></div></div><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/webdriver/promise.js.src.html#l943">code &raquo;</a><span class="member"><a name="webdriver.promise.ControlFlow.superClass_">webdriver.promise.ControlFlow.superClass_</a> : <code class="type"><a href="class_webdriver_EventEmitter.html">webdriver.EventEmitter.prototype</a></code></span></div></summary></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>No data</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>No data</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>No data</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script>