2020-01-09 23:49:22 +01: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-30 01:00:56 +01:00
|
|
|
import * as path from 'path';
|
|
|
|
|
import { Tracer } from '../trace/tracer';
|
2020-12-10 00:06:57 +01:00
|
|
|
import { Android } from './android/android';
|
|
|
|
|
import { AdbBackend } from './android/backendAdb';
|
2021-02-01 01:37:13 +01:00
|
|
|
import { PlaywrightOptions } from './browser';
|
2020-08-23 00:46:42 +02:00
|
|
|
import { Chromium } from './chromium/chromium';
|
2020-12-10 00:06:57 +01:00
|
|
|
import { Electron } from './electron/electron';
|
2020-08-24 02:05:58 +02:00
|
|
|
import { Firefox } from './firefox/firefox';
|
2020-09-03 01:15:43 +02:00
|
|
|
import { serverSelectors } from './selectors';
|
2021-01-30 01:00:56 +01:00
|
|
|
import { HarTracer } from './supplements/har/harTracer';
|
|
|
|
|
import { InspectorController } from './supplements/inspectorController';
|
2020-12-10 00:06:57 +01:00
|
|
|
import { WebKit } from './webkit/webkit';
|
2021-02-09 01:02:49 +01:00
|
|
|
import { Registry } from '../utils/registry';
|
2020-01-09 23:49:22 +01:00
|
|
|
|
2020-01-24 23:49:47 +01:00
|
|
|
export class Playwright {
|
2020-09-03 01:15:43 +02:00
|
|
|
readonly selectors = serverSelectors;
|
2020-07-25 01:36:00 +02:00
|
|
|
readonly chromium: Chromium;
|
2020-12-10 00:06:57 +01:00
|
|
|
readonly android: Android;
|
|
|
|
|
readonly electron: Electron;
|
2020-07-25 01:36:00 +02:00
|
|
|
readonly firefox: Firefox;
|
|
|
|
|
readonly webkit: WebKit;
|
2021-02-01 01:37:13 +01:00
|
|
|
readonly options: PlaywrightOptions;
|
2020-01-24 23:49:47 +01:00
|
|
|
|
2021-02-09 01:02:49 +01:00
|
|
|
constructor(isInternal: boolean) {
|
2021-02-01 01:37:13 +01:00
|
|
|
this.options = {
|
|
|
|
|
isInternal,
|
2021-02-09 01:02:49 +01:00
|
|
|
registry: new Registry(path.join(__dirname, '..', '..')),
|
|
|
|
|
|
2021-02-01 01:37:13 +01:00
|
|
|
contextListeners: isInternal ? [] : [
|
|
|
|
|
new InspectorController(),
|
|
|
|
|
new Tracer(),
|
|
|
|
|
new HarTracer()
|
|
|
|
|
]
|
|
|
|
|
};
|
2021-02-09 01:02:49 +01: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 23:49:47 +01:00
|
|
|
}
|
2020-01-09 23:49:22 +01:00
|
|
|
}
|
2021-01-30 01:00:56 +01:00
|
|
|
|
2021-02-01 01:37:13 +01:00
|
|
|
export function createPlaywright(isInternal = false) {
|
2021-02-09 01:02:49 +01:00
|
|
|
return new Playwright(isInternal);
|
2021-01-30 01:00:56 +01:00
|
|
|
}
|