mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-01 11:50:54 +08:00
Update webdriver.promise.Promise
Link: https://github.com/SeleniumHQ/selenium/commit/762a18540c7a78ca15599dedf4af3145ed7dd3fb
This commit is contained in:
@@ -100,7 +100,8 @@ function TestFirefoxProfile() {
|
||||
|
||||
function TestExecutors() {
|
||||
var exec: webdriver.CommandExecutor = executors.createExecutor("url");
|
||||
exec = executors.createExecutor(new webdriver.promise.Promise<string>());
|
||||
var promise: webdriver.promise.Promise<string>;
|
||||
exec = executors.createExecutor(promise);
|
||||
}
|
||||
|
||||
function TestBuilder() {
|
||||
@@ -694,7 +695,7 @@ function TestWebDriverWindow() {
|
||||
|
||||
function TestWebDriver() {
|
||||
var session: webdriver.Session = new webdriver.Session('ABC', webdriver.Capabilities.android());
|
||||
var sessionPromise: webdriver.promise.Promise<webdriver.Session> = new webdriver.promise.Promise<webdriver.Session>();
|
||||
var sessionPromise: webdriver.promise.Promise<webdriver.Session>;
|
||||
var executor: webdriver.CommandExecutor = executors.createExecutor("http://someserver");
|
||||
var flow: webdriver.promise.ControlFlow = new webdriver.promise.ControlFlow();
|
||||
var driver: webdriver.WebDriver = new webdriver.WebDriver(session, executor);
|
||||
@@ -780,10 +781,11 @@ function TestWebElement() {
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
var promise: webdriver.promise.Promise<webdriver.IWebElementId>;
|
||||
var element: webdriver.WebElement;
|
||||
|
||||
element = new webdriver.WebElement(driver, { ELEMENT: 'ID' });
|
||||
element = new webdriver.WebElement(driver, new webdriver.promise.Promise<webdriver.IWebElementId>());
|
||||
element = new webdriver.WebElement(driver, promise);
|
||||
|
||||
var voidPromise: webdriver.promise.Promise<void>;
|
||||
var stringPromise: webdriver.promise.Promise<string>;
|
||||
@@ -896,12 +898,12 @@ function TestPromiseModule() {
|
||||
var str: string = cancellationError.message;
|
||||
str = cancellationError.name;
|
||||
|
||||
var stringPromise: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>();
|
||||
var stringPromise: webdriver.promise.Promise<string>;
|
||||
var numberPromise: webdriver.promise.Promise<number>;
|
||||
var booleanPromise: webdriver.promise.Promise<boolean>;
|
||||
var voidPromise: webdriver.promise.Promise<void>;
|
||||
|
||||
webdriver.promise.all([new webdriver.promise.Promise<string>()]).then(function (values: string[]) { });
|
||||
webdriver.promise.all([stringPromise]).then(function (values: string[]) { });
|
||||
|
||||
webdriver.promise.asap('abc', function(value: any){ return true; });
|
||||
webdriver.promise.asap('abc', function(value: any){}, function(err: any) { return 'ABC'; });
|
||||
@@ -1070,7 +1072,17 @@ function TestDeferred() {
|
||||
}
|
||||
|
||||
function TestPromiseClass() {
|
||||
var promise: webdriver.promise.Promise<string> = new webdriver.promise.Promise<string>();
|
||||
var controlFlow: webdriver.promise.ControlFlow;
|
||||
var promise: webdriver.promise.Promise<string>;
|
||||
promise = new webdriver.promise.Promise<string>(function(
|
||||
onFulfilled: (value: string)=>void,
|
||||
onRejected: ()=>void) { });
|
||||
promise = new webdriver.promise.Promise<string>(function(
|
||||
onFulfilled: (value: webdriver.promise.Promise<string>)=>void,
|
||||
onRejected: ()=>void) { });
|
||||
promise = new webdriver.promise.Promise<string>(function(
|
||||
onFulfilled: (value: string)=>void,
|
||||
onRejected: ()=>void) { }, controlFlow);
|
||||
|
||||
promise.cancel('Abort');
|
||||
|
||||
|
||||
+25
-14
@@ -1289,28 +1289,39 @@ declare module webdriver {
|
||||
static isImplementation(object: any): boolean;
|
||||
}
|
||||
|
||||
interface IFulfilledCallback<T> {
|
||||
(value: T|IThenable<T>|Thenable<T>|void): void;
|
||||
}
|
||||
|
||||
interface IRejectedCallback {
|
||||
(reason: any): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the eventual value of a completed operation. Each promise may be
|
||||
* in one of three states: pending, resolved, or rejected. Each promise starts
|
||||
* in one of three states: pending, fulfilled, or rejected. Each promise starts
|
||||
* in the pending state and may make a single transition to either a
|
||||
* fulfilled or failed state.
|
||||
* fulfilled or rejected state, at which point the promise is considered
|
||||
* resolved.
|
||||
*
|
||||
* <p/>This class is based on the Promise/A proposal from CommonJS. Additional
|
||||
* functions are provided for API compatibility with Dojo Deferred objects.
|
||||
*
|
||||
* @see http://wiki.commonjs.org/wiki/Promises/A
|
||||
* @implements {promise.Thenable<T>}
|
||||
* @template T
|
||||
* @see http://promises-aplus.github.io/promises-spec/
|
||||
*/
|
||||
class Promise<T> implements IThenable<T> {
|
||||
|
||||
//region Constructors
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://wiki.commonjs.org/wiki/Promises/A
|
||||
* @param {function(
|
||||
* function((T|IThenable<T>|Thenable)=),
|
||||
* function(*=))} resolver
|
||||
* Function that is invoked immediately to begin computation of this
|
||||
* promise's value. The function should accept a pair of callback functions,
|
||||
* one for fulfilling the promise and another for rejecting it.
|
||||
* @param {promise.ControlFlow=} opt_flow The control flow
|
||||
* this instance was created under. Defaults to the currently active flow.
|
||||
* @constructor
|
||||
*/
|
||||
constructor();
|
||||
|
||||
//endregion
|
||||
constructor(resolver: (onFulfilled: IFulfilledCallback<T>, onRejected: IRejectedCallback)=>void, opt_flow?: ControlFlow);
|
||||
constructor(); // For angular-protractor/angular-protractor-tests.ts
|
||||
|
||||
//region Methods
|
||||
|
||||
|
||||
Reference in New Issue
Block a user