deferred_executor.js 1.15 KB
Newer Older
jatuporn Tonggasem's avatar
jatuporn Tonggasem committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
"use strict";
/*
 * Wraps a promised {@link Executor}, ensuring no commands are executed until
 * the wrapped executor has been fully resolved.
 *
 * selenium-webdriver uses this internally, and we overwrite it to give it the
 * defineCommand() function
 *
 * Based off of
 * https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/lib/command.js#L240
 *
 * @implements {Executor}
 */
var DeferredExecutor = (function () {
    /**
     * @param {!Promise<Executor>} delegate The promised delegate, which
     *     may be provided by any promise-like thenable object.
     */
    function DeferredExecutor(delegate) {
        /** @override */
        this.execute = function (command) {
            return delegate.then(function (executor) {
                return executor.execute(command);
            });
        };
        this.defineCommand = function (name, method, path) {
            delegate.then(function (executor) {
                executor.defineCommand(name, method, path);
            });
        };
    }
    return DeferredExecutor;
}());
exports.DeferredExecutor = DeferredExecutor;
//# sourceMappingURL=deferred_executor.js.map