1 | import {bind, provide, Provider} from 'angular2/src/core/di';
|
2 | import {isPresent, StringWrapper} from 'angular2/src/facade/lang';
|
3 | import {WebDriverExtension, PerfLogFeatures} from '../web_driver_extension';
|
4 | import {WebDriverAdapter} from '../web_driver_adapter';
|
5 |
|
6 | export class FirefoxDriverExtension extends WebDriverExtension {
|
7 | static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
8 |
|
9 | private _profilerStarted: boolean;
|
10 |
|
11 | constructor(private _driver: WebDriverAdapter) {
|
12 | super();
|
13 | this._profilerStarted = false;
|
14 | }
|
15 |
|
16 | gc() { return this._driver.executeScript('window.forceGC()'); }
|
17 |
|
18 | timeBegin(name: string): Promise<any> {
|
19 | if (!this._profilerStarted) {
|
20 | this._profilerStarted = true;
|
21 | this._driver.executeScript('window.startProfiler();');
|
22 | }
|
23 | return this._driver.executeScript('window.markStart("' + name + '");');
|
24 | }
|
25 |
|
26 | timeEnd(name: string, restartName: string = null): Promise<any> {
|
27 | var script = 'window.markEnd("' + name + '");';
|
28 | if (isPresent(restartName)) {
|
29 | script += 'window.markStart("' + restartName + '");';
|
30 | }
|
31 | return this._driver.executeScript(script);
|
32 | }
|
33 |
|
34 | readPerfLog(): Promise<any> {
|
35 | return this._driver.executeAsyncScript('var cb = arguments[0]; window.getProfile(cb);');
|
36 | }
|
37 |
|
38 | perfLogFeatures(): PerfLogFeatures { return new PerfLogFeatures({render: true, gc: true}); }
|
39 |
|
40 | supports(capabilities: {[key: string]: any}): boolean {
|
41 | return StringWrapper.equals(capabilities['browserName'].toLowerCase(), 'firefox');
|
42 | }
|
43 | }
|
44 |
|
45 | var _PROVIDERS = [
|
46 | bind(FirefoxDriverExtension)
|
47 | .toFactory((driver) => new FirefoxDriverExtension(driver), [WebDriverAdapter])
|
48 | ];
|