2020-01-09 14:49:22 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-01-29 16:00:56 -08:00
|
|
|
import * as path from 'path';
|
|
|
|
import { Tracer } from '../trace/tracer';
|
2020-12-09 15:06:57 -08:00
|
|
|
import { Android } from './android/android';
|
|
|
|
import { AdbBackend } from './android/backendAdb';
|
2021-01-31 16:37:13 -08:00
|
|
|
import { PlaywrightOptions } from './browser';
|
2020-08-22 15:46:42 -07:00
|
|
|
import { Chromium } from './chromium/chromium';
|
2020-12-09 15:06:57 -08:00
|
|
|
import { Electron } from './electron/electron';
|
2020-08-23 17:05:58 -07:00
|
|
|
import { Firefox } from './firefox/firefox';
|
2020-09-02 16:15:43 -07:00
|
|
|
import { serverSelectors } from './selectors';
|
2021-01-29 16:00:56 -08:00
|
|
|
import { HarTracer } from './supplements/har/harTracer';
|
|
|
|
import { InspectorController } from './supplements/inspectorController';
|
2020-12-09 15:06:57 -08:00
|
|
|
import { WebKit } from './webkit/webkit';
|
2021-02-08 16:02:49 -08:00
|
|
|
import { Registry } from '../utils/registry';
|
2020-01-09 14:49:22 -08:00
|
|
|
|
2020-01-24 14:49:47 -08:00
|
|
|
export class Playwright {
|
2020-09-02 16:15:43 -07:00
|
|
|
readonly selectors = serverSelectors;
|
2020-07-24 16:36:00 -07:00
|
|
|
readonly chromium: Chromium;
|
2020-12-09 15:06:57 -08:00
|
|
|
readonly android: Android;
|
|
|
|
readonly electron: Electron;
|
2020-07-24 16:36:00 -07:00
|
|
|
readonly firefox: Firefox;
|
|
|
|
readonly webkit: WebKit;
|
2021-01-31 16:37:13 -08:00
|
|
|
readonly options: PlaywrightOptions;
|
2020-01-24 14:49:47 -08:00
|
|
|
|
2021-02-08 16:02:49 -08:00
|
|
|
constructor(isInternal: boolean) {
|
2021-01-31 16:37:13 -08:00
|
|
|
this.options = {
|
|
|
|
isInternal,
|
2021-02-08 16:02:49 -08:00
|
|
|
registry: new Registry(path.join(__dirname, '..', '..')),
|
|
|
|
|
2021-01-31 16:37:13 -08:00
|
|
|
contextListeners: isInternal ? [] : [
|
|
|
|
new InspectorController(),
|
|
|
|
new Tracer(),
|
|
|
|
new HarTracer()
|
|
|
|
]
|
|
|
|
};
|
2021-02-08 16:02:49 -08:00
|
|
|
this.chromium = new Chromium(this.options);
|
|
|
|
this.firefox = new Firefox(this.options);
|
|
|
|
this.webkit = new WebKit(this.options);
|
|
|
|
this.electron = new Electron(this.options);
|
|
|
|
this.android = new Android(new AdbBackend(), this.options);
|
2020-01-24 14:49:47 -08:00
|
|
|
}
|
2020-01-09 14:49:22 -08:00
|
|
|
}
|
2021-01-29 16:00:56 -08:00
|
|
|
|
2021-01-31 16:37:13 -08:00
|
|
|
export function createPlaywright(isInternal = false) {
|
2021-02-08 16:02:49 -08:00
|
|
|
return new Playwright(isInternal);
|
2021-01-29 16:00:56 -08:00
|
|
|
}
|