| 35 | */ |
| 36 | export abstract class WebDriverExtension { |
| 37 | static provideFirstSupported(childTokens: any[]): any[] { |
| 38 | const res = [ |
| 39 | { |
| 40 | provide: _CHILDREN, |
| 41 | useFactory: (injector: Injector) => childTokens.map((token) => injector.get(token)), |
| 42 | deps: [Injector], |
| 43 | }, |
| 44 | { |
| 45 | provide: WebDriverExtension, |
| 46 | useFactory: (children: WebDriverExtension[], capabilities: {[key: string]: any}) => { |
| 47 | let delegate: WebDriverExtension = undefined!; |
| 48 | children.forEach((extension) => { |
| 49 | if (extension.supports(capabilities)) { |
| 50 | delegate = extension; |
| 51 | } |
| 52 | }); |
| 53 | if (!delegate) { |
| 54 | throw new Error('Could not find a delegate for given capabilities!'); |
| 55 | } |
| 56 | return delegate; |
| 57 | }, |
| 58 | deps: [_CHILDREN, Options.CAPABILITIES], |
| 59 | }, |
| 60 | ]; |
| 61 | return res; |
| 62 | } |
| 63 | |
| 64 | gc(): Promise<any> { |
| 65 | throw new Error('NYI'); |