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

This commit is contained in:
Dmitry Gozman 2021-01-13 17:02:53 -08:00 committed by GitHub
parent 7ff86a848a
commit e3ebba5573
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 2 additions and 144 deletions

View file

@ -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 {

View file

@ -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))) };
}
}

View file

@ -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 = {

View file

@ -1396,14 +1396,6 @@ Frame:
returns:
element: ElementHandle?
extendInjectedScript:
experimental: True
parameters:
source: string
arg: SerializedArgument
returns:
handle: JSHandle
events:
loadstate:

View file

@ -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,

View file

@ -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) {
}
}

View file

@ -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';

101
types/trace.d.ts vendored
View file

@ -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[],
};

View file

@ -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([]);