* @param {function(new: WebDriver, !IThenable<!Session>, ...?)} ctor * @param {...?} args * @return {!ThenableWebDriver}
(ctor, ...args)
| 124 | * @return {!ThenableWebDriver} |
| 125 | */ |
| 126 | function createDriver(ctor, ...args) { |
| 127 | let thenableWebDriverProxy = THENABLE_DRIVERS.get(ctor) |
| 128 | if (!thenableWebDriverProxy) { |
| 129 | /** |
| 130 | * @extends {WebDriver} // Needed since `ctor` is dynamically typed. |
| 131 | * @implements {ThenableWebDriver} |
| 132 | */ |
| 133 | thenableWebDriverProxy = class extends ctor { |
| 134 | /** |
| 135 | * @param {!IThenable<!Session>} session |
| 136 | * @param {...?} rest |
| 137 | */ |
| 138 | constructor(session, ...rest) { |
| 139 | super(session, ...rest) |
| 140 | |
| 141 | const pd = this.getSession().then((session) => { |
| 142 | return new ctor(session, ...rest) |
| 143 | }) |
| 144 | |
| 145 | /** @override */ |
| 146 | this.then = pd.then.bind(pd) |
| 147 | |
| 148 | /** @override */ |
| 149 | this.catch = pd.catch.bind(pd) |
| 150 | } |
| 151 | } |
| 152 | THENABLE_DRIVERS.set(ctor, thenableWebDriverProxy) |
| 153 | } |
| 154 | return thenableWebDriverProxy.createSession(...args) |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Creates new {@link webdriver.WebDriver WebDriver} instances. The environment |
no test coverage detected