deferred_executor.js 1.1 KB

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