Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: cleanup code that is not used by cli anymore (#5005)

Dmitry Gozmane3ebba557397
diff --git a/src/client/frame.ts b/src/client/frame.ts
index c4a5f2b85f..f60b9684a2 100644
--- a/src/client/frame.ts
+++ b/src/client/frame.ts
@@ -464,12 +464,6 @@ export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameIni
return (await this._channel.title()).value;
});
}
-
- // TODO: remove once playwright-cli does not use this one anymore.
- async _extendInjectedScript<Arg>(source: string, arg?: Arg): Promise<JSHandle> {
- const result = await this._channel.extendInjectedScript({ source, arg: serializeArgument(arg) });
- return JSHandle.from(result.handle);
- }
}
export function verifyLoadState(name: string, waitUntil: LifecycleEvent): LifecycleEvent {
diff --git a/src/dispatchers/frameDispatcher.ts b/src/dispatchers/frameDispatcher.ts
index e249fe5290..226a16990b 100644
--- a/src/dispatchers/frameDispatcher.ts
+++ b/src/dispatchers/frameDispatcher.ts
@@ -233,8 +233,4 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer
async title(): Promise<channels.FrameTitleResult> {
return { value: await this._frame.title() };
}
-
- async extendInjectedScript(params: channels.FrameExtendInjectedScriptParams): Promise<channels.FrameExtendInjectedScriptResult> {
- return { handle: createHandle(this._scope, await this._frame.extendInjectedScript(params.source, parseArgument(params.arg))) };
- }
}
diff --git a/src/protocol/channels.ts b/src/protocol/channels.ts
index c54e5a5c4e..582238705e 100644
--- a/src/protocol/channels.ts
+++ b/src/protocol/channels.ts
@@ -1209,7 +1209,6 @@ export interface FrameChannel extends Channel {
uncheck(params: FrameUncheckParams, metadata?: Metadata): Promise<FrameUncheckResult>;
waitForFunction(params: FrameWaitForFunctionParams, metadata?: Metadata): Promise<FrameWaitForFunctionResult>;
waitForSelector(params: FrameWaitForSelectorParams, metadata?: Metadata): Promise<FrameWaitForSelectorResult>;
- extendInjectedScript(params: FrameExtendInjectedScriptParams, metadata?: Metadata): Promise<FrameExtendInjectedScriptResult>;
}
export type FrameLoadstateEvent = {
add?: 'load' | 'domcontentloaded' | 'networkidle',
@@ -1669,16 +1668,6 @@ export type FrameWaitForSelectorOptions = {
export type FrameWaitForSelectorResult = {
element?: ElementHandleChannel,
};
-export type FrameExtendInjectedScriptParams = {
- source: string,
- arg: SerializedArgument,
-};
-export type FrameExtendInjectedScriptOptions = {
-
-};
-export type FrameExtendInjectedScriptResult = {
- handle: JSHandleChannel,
-};
// ----------- Worker -----------
export type WorkerInitializer = {
diff --git a/src/protocol/protocol.yml b/src/protocol/protocol.yml
index 4573bb64da..afb0948384 100644
--- a/src/protocol/protocol.yml
+++ b/src/protocol/protocol.yml
@@ -1396,14 +1396,6 @@ Frame:
returns:
element: ElementHandle?
- extendInjectedScript:
- experimental: True
- parameters:
- source: string
- arg: SerializedArgument
- returns:
- handle: JSHandle
-
events:
loadstate:
diff --git a/src/protocol/validator.ts b/src/protocol/validator.ts
index 12f11bd1a5..ceb75d7e7a 100644
--- a/src/protocol/validator.ts
+++ b/src/protocol/validator.ts
@@ -679,10 +679,6 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
timeout: tOptional(tNumber),
state: tOptional(tEnum(['attached', 'detached', 'visible', 'hidden'])),
});
- scheme.FrameExtendInjectedScriptParams = tObject({
- source: tString,
- arg: tType('SerializedArgument'),
- });
scheme.WorkerEvaluateExpressionParams = tObject({
expression: tString,
isFunction: tBoolean,
diff --git a/src/utils/binaryPaths.ts b/src/utils/binaryPaths.ts
index 7542e5d7e6..6c10df700b 100644
--- a/src/utils/binaryPaths.ts
+++ b/src/utils/binaryPaths.ts
@@ -34,18 +34,11 @@ export function ffmpegExecutable(): string | undefined {
}
function pathToExecutable(relative: string[]): string | undefined {
- const defaultPath = path.join(__dirname, '..', '..', ...relative);
- const localPath = path.join(path.dirname(process.argv[0]), relative[relative.length - 1]);
try {
+ const defaultPath = path.join(__dirname, '..', '..', ...relative);
if (fs.existsSync(defaultPath))
return defaultPath;
} catch (e) {
}
-
- try {
- if (fs.existsSync(localPath))
- return localPath;
- } catch (e) {
- }
}
diff --git a/test/trace.spec.ts b/test/trace.spec.ts
index a2cb8b1fc3..135edb131d 100644
--- a/test/trace.spec.ts
+++ b/test/trace.spec.ts
@@ -15,7 +15,7 @@
*/
import { it, expect } from './fixtures';
-import type * as trace from '../types/trace';
+import type * as trace from '../src/trace/traceTypes';
import * as path from 'path';
import * as fs from 'fs';
diff --git a/types/trace.d.ts b/types/trace.d.ts
deleted file mode 100644
index 54b31d68a4..0000000000
--- a/types/trace.d.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-/**
- * 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.
- */
-
-export type ContextCreatedTraceEvent = {
- type: 'context-created',
- browserName: string,
- contextId: string,
- deviceScaleFactor: number,
- isMobile: boolean,
- viewportSize?: { width: number, height: number },
-};
-
-export type ContextDestroyedTraceEvent = {
- type: 'context-destroyed',
- contextId: string,
-};
-
-export type NetworkResourceTraceEvent = {
- type: 'resource',
- contextId: string,
- pageId: string,
- frameId: string,
- url: string,
- contentType: string,
- responseHeaders: { name: string, value: string }[],
- sha1: string,
-};
-
-export type PageCreatedTraceEvent = {
- type: 'page-created',
- contextId: string,
- pageId: string,
-};
-
-export type PageDestroyedTraceEvent = {
- type: 'page-destroyed',
- contextId: string,
- pageId: string,
-};
-
-export type PageVideoTraceEvent = {
- type: 'page-video',
- contextId: string,
- pageId: string,
- fileName: string,
-};
-
-export type ActionTraceEvent = {
- type: 'action',
- contextId: string,
- action: string,
- pageId?: string,
- selector?: string,
- label?: string,
- value?: string,
- startTime?: number,
- endTime?: number,
- logs?: string[],
- snapshot?: {
- sha1: string,
- duration: number,
- },
- stack?: string,
- error?: string,
-};
-
-export type TraceEvent =
- ContextCreatedTraceEvent |
- ContextDestroyedTraceEvent |
- PageCreatedTraceEvent |
- PageDestroyedTraceEvent |
- PageVideoTraceEvent |
- NetworkResourceTraceEvent |
- ActionTraceEvent;
-
-
-export type FrameSnapshot = {
- frameId: string,
- url: string,
- html: string,
- resourceOverrides: { url: string, sha1: string }[],
-};
-
-export type PageSnapshot = {
- viewportSize?: { width: number, height: number },
- // First frame is the main frame.
- frames: FrameSnapshot[],
-};
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js
index 47eb2f4a43..522e9bbfd1 100644
--- a/utils/generate_types/index.js
+++ b/utils/generate_types/index.js
@@ -36,7 +36,6 @@ let hadChanges = false;
if (!fs.existsSync(typesDir))
fs.mkdirSync(typesDir)
writeFile(path.join(typesDir, 'protocol.d.ts'), fs.readFileSync(path.join(PROJECT_DIR, 'src', 'server', 'chromium', 'protocol.ts'), 'utf8'));
- writeFile(path.join(typesDir, 'trace.d.ts'), fs.readFileSync(path.join(PROJECT_DIR, 'src', 'trace', 'traceTypes.ts'), 'utf8'));
documentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'api'));
documentation.filterForLanguage('js');
documentation.copyDocsFromSuperclasses([]);