1 | import {bind, provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
|
2 |
|
3 | import {isBlank, isPresent} from 'angular2/src/facade/lang';
|
4 | import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
|
5 |
|
6 | import {Options} from './common_options';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | export abstract class WebDriverExtension {
|
14 | static bindTo(childTokens: any[]): Provider[] {
|
15 | var res = [
|
16 | bind(_CHILDREN)
|
17 | .toFactory((injector: Injector) => childTokens.map(token => injector.get(token)),
|
18 | [Injector]),
|
19 | bind(WebDriverExtension)
|
20 | .toFactory(
|
21 | (children: WebDriverExtension[], capabilities) => {
|
22 | var delegate;
|
23 | children.forEach(extension => {
|
24 | if (extension.supports(capabilities)) {
|
25 | delegate = extension;
|
26 | }
|
27 | });
|
28 | if (isBlank(delegate)) {
|
29 | throw new BaseException('Could not find a delegate for given capabilities!');
|
30 | }
|
31 | return delegate;
|
32 | },
|
33 | [_CHILDREN, Options.CAPABILITIES])
|
34 | ];
|
35 | return res;
|
36 | }
|
37 |
|
38 | gc(): Promise<any> { throw new BaseException('NYI'); }
|
39 |
|
40 | timeBegin(name: string): Promise<any> { throw new BaseException('NYI'); }
|
41 |
|
42 | timeEnd(name: string, restartName: string): Promise<any> { throw new BaseException('NYI'); }
|
43 |
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 | readPerfLog(): Promise<any[]> { throw new BaseException('NYI'); }
|
58 |
|
59 | perfLogFeatures(): PerfLogFeatures { throw new BaseException('NYI'); }
|
60 |
|
61 | supports(capabilities: {[key: string]: any}): boolean { return true; }
|
62 | }
|
63 |
|
64 | export class PerfLogFeatures {
|
65 | render: boolean;
|
66 | gc: boolean;
|
67 | frameCapture: boolean;
|
68 | userTiming: boolean;
|
69 |
|
70 | constructor(
|
71 | {render = false, gc = false, frameCapture = false, userTiming = false}:
|
72 | {render?: boolean, gc?: boolean, frameCapture?: boolean, userTiming?: boolean} = {}) {
|
73 | this.render = render;
|
74 | this.gc = gc;
|
75 | this.frameCapture = frameCapture;
|
76 | this.userTiming = userTiming;
|
77 | }
|
78 | }
|
79 |
|
80 | var _CHILDREN = new OpaqueToken('WebDriverExtension.children');
|