Skip to content

Commit 9c6d612

Browse files
committed
[js] Loosen API contracts to the Thenable promise-like interface
This is the first step in a long (and not yet documented) plan to phase out the control flow and managed promises in favor of async functions (coming in ES2017)
1 parent 098063f commit 9c6d612

File tree

7 files changed

+96
-99
lines changed

7 files changed

+96
-99
lines changed

javascript/node/selenium-webdriver/chrome.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ class Driver extends webdriver.WebDriver {
728728
/**
729729
* Schedules a command to launch Chrome App with given ID.
730730
* @param {string} id ID of the App to launch.
731-
* @return {!promise.Promise<void>} A promise that will be resolved
731+
* @return {!promise.Thenable<void>} A promise that will be resolved
732732
* when app is launched.
733733
*/
734734
launchApp(id) {

javascript/node/selenium-webdriver/firefox/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ class Driver extends webdriver.WebDriver {
637637
/**
638638
* Get the context that is currently in effect.
639639
*
640-
* @return {!promise.Promise<Context>} Current context.
640+
* @return {!promise.Thenable<Context>} Current context.
641641
*/
642642
getContext() {
643643
return this.schedule(
@@ -657,7 +657,7 @@ class Driver extends webdriver.WebDriver {
657657
*
658658
* Use your powers wisely.
659659
*
660-
* @param {!promise.Promise<void>} ctx The context to switch to.
660+
* @param {!promise.Thenable<void>} ctx The context to switch to.
661661
*/
662662
setContext(ctx) {
663663
return this.schedule(

javascript/node/selenium-webdriver/lib/actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class ActionSequence {
107107
/**
108108
* Executes this action sequence.
109109
*
110-
* @return {!./promise.Promise} A promise that will be resolved once
110+
* @return {!./promise.Thenable} A promise that will be resolved once
111111
* this sequence has completed.
112112
*/
113113
perform() {
@@ -415,7 +415,7 @@ class TouchSequence {
415415

416416
/**
417417
* Executes this action sequence.
418-
* @return {!./promise.Promise} A promise that will be resolved once
418+
* @return {!./promise.Thenable} A promise that will be resolved once
419419
* this sequence has completed.
420420
*/
421421
perform() {

javascript/node/selenium-webdriver/lib/promise.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,12 +2030,12 @@ class ControlFlow extends events.EventEmitter {
20302030
* the task function is a generator, the task will be executed using
20312031
* {@link ./promise.consume consume()}.
20322032
*
2033-
* @param {function(): (T|ManagedPromise<T>)} fn The function to
2034-
* call to start the task. If the function returns a
2035-
* {@link ManagedPromise}, this instance will wait for it to be
2036-
* resolved before starting the next task.
2033+
* @param {function(): (T|IThenable<T>)} fn The function to
2034+
* call to start the task. If the function returns a promise,
2035+
* this instance will wait for it to be resolved before starting the
2036+
* next task.
20372037
* @param {string=} opt_description A description of the task.
2038-
* @return {!ManagedPromise<T>} A promise that will be resolved
2038+
* @return {!Thenable<T>} A promise that will be resolved
20392039
* with the result of the action.
20402040
* @template T
20412041
*/
@@ -2066,7 +2066,7 @@ class ControlFlow extends events.EventEmitter {
20662066
*
20672067
* @param {number} ms The timeout delay, in milliseconds.
20682068
* @param {string=} opt_description A description to accompany the timeout.
2069-
* @return {!ManagedPromise} A promise that will be resolved with
2069+
* @return {!Thenable} A promise that will be resolved with
20702070
* the result of the action.
20712071
*/
20722072
timeout(ms, opt_description) {
@@ -2098,14 +2098,14 @@ class ControlFlow extends events.EventEmitter {
20982098
* If this function is invoked with `timeout === 0`, or the timeout is
20992099
* omitted, the flow will wait indefinitely for the condition to be satisfied.
21002100
*
2101-
* @param {(!ManagedPromise<T>|function())} condition The condition to poll,
2101+
* @param {(!IThenable<T>|function())} condition The condition to poll,
21022102
* or a promise to wait on.
21032103
* @param {number=} opt_timeout How long to wait, in milliseconds, for the
21042104
* condition to hold before timing out. If omitted, the flow will wait
21052105
* indefinitely.
21062106
* @param {string=} opt_message An optional error message to include if the
21072107
* wait times out; defaults to the empty string.
2108-
* @return {!ManagedPromise<T>} A promise that will be fulfilled
2108+
* @return {!Thenable<T>} A promise that will be fulfilled
21092109
* when the condition has been satisified. The promise shall be rejected
21102110
* if the wait times out waiting for the condition.
21112111
* @throws {TypeError} If condition is not a function or promise or if timeout
@@ -2900,8 +2900,7 @@ function controlFlow() {
29002900
* a promise that resolves to the callback result.
29012901
* @param {function(!ControlFlow)} callback The entry point
29022902
* to the newly created flow.
2903-
* @return {!ManagedPromise} A promise that resolves to the callback
2904-
* result.
2903+
* @return {!Thenable} A promise that resolves to the callback result.
29052904
*/
29062905
function createFlow(callback) {
29072906
var flow = new ControlFlow;

0 commit comments

Comments
 (0)