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-02-11 15:36:15 +01:00
|
|
|
import path from 'path';
|
2021-01-30 01:00:56 +01:00
|
|
|
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';
|
2021-02-09 23:44:48 +01:00
|
|
|
import { Selectors, 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';
|
2021-02-11 06:44:22 +01:00
|
|
|
import { InstrumentationListener, multiplexInstrumentation, SdkObject } from './instrumentation';
|
2020-01-09 23:49:22 +01:00
|
|
|
|
2021-02-09 18:00:00 +01:00
|
|
|
export class Playwright extends SdkObject {
|
|
|
|
|
readonly selectors: Selectors;
|
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-11 06:44:22 +01:00
|
|
|
const listeners: InstrumentationListener[] = [];
|
|
|
|
|
if (!isInternal) {
|
|
|
|
|
listeners.push(new Tracer());
|
|
|
|
|
listeners.push(new HarTracer());
|
|
|
|
|
listeners.push(new InspectorController());
|
|
|
|
|
}
|
|
|
|
|
const instrumentation = multiplexInstrumentation(listeners);
|
2021-02-09 23:44:48 +01:00
|
|
|
super({ attribution: {}, instrumentation } as any);
|
2021-02-01 01:37:13 +01:00
|
|
|
this.options = {
|
2021-02-09 01:02:49 +01:00
|
|
|
registry: new Registry(path.join(__dirname, '..', '..')),
|
2021-02-09 18:00:00 +01:00
|
|
|
rootSdkObject: this,
|
2021-02-01 01:37:13 +01:00
|
|
|
};
|
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);
|
2021-02-09 23:44:48 +01:00
|
|
|
this.selectors = serverSelectors;
|
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
|
|
|
}
|