2020-08-28 10:51:55 -07: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.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-02-27 15:29:20 -08:00
|
|
|
import type { Point, SerializedError, StackFrame } from '@protocol/channels';
|
2023-03-06 18:49:14 -08:00
|
|
|
import type { Language } from '../../playwright-core/src/utils/isomorphic/locatorGenerators';
|
2022-09-20 18:41:51 -07:00
|
|
|
import type { FrameSnapshot, ResourceSnapshot } from './snapshot';
|
|
|
|
|
|
|
|
|
|
export type Size = { width: number, height: number };
|
2021-10-12 13:42:50 -08:00
|
|
|
|
2022-03-25 13:12:00 -08:00
|
|
|
// Make sure you add _modernize_N_to_N1(event: any) to traceModel.ts.
|
2023-09-19 16:21:09 -07:00
|
|
|
export type VERSION = 5;
|
2021-10-12 13:42:50 -08:00
|
|
|
|
|
|
|
|
export type BrowserContextEventOptions = {
|
|
|
|
|
viewport?: Size,
|
|
|
|
|
deviceScaleFactor?: number,
|
|
|
|
|
isMobile?: boolean,
|
2021-11-09 22:13:51 -08:00
|
|
|
userAgent?: string,
|
2021-10-12 13:42:50 -08:00
|
|
|
};
|
2021-01-29 06:57:57 -08:00
|
|
|
|
2020-08-28 10:51:55 -07:00
|
|
|
export type ContextCreatedTraceEvent = {
|
2021-07-02 14:33:38 -07:00
|
|
|
version: number,
|
2021-05-13 22:36:34 -07:00
|
|
|
type: 'context-options',
|
2020-08-28 10:51:55 -07:00
|
|
|
browserName: string,
|
2023-09-11 23:06:56 +02:00
|
|
|
channel?: string,
|
2021-11-09 22:13:51 -08:00
|
|
|
platform: string,
|
|
|
|
|
wallTime: number,
|
2021-11-01 20:23:35 -08:00
|
|
|
title?: string,
|
2022-10-18 22:23:40 -04:00
|
|
|
options: BrowserContextEventOptions,
|
|
|
|
|
sdkLanguage?: Language,
|
2023-02-17 11:19:53 -08:00
|
|
|
testIdAttributeName?: string,
|
2020-09-11 11:34:53 -07:00
|
|
|
};
|
|
|
|
|
|
2021-04-08 05:32:12 +08:00
|
|
|
export type ScreencastFrameTraceEvent = {
|
2021-04-24 20:39:48 -07:00
|
|
|
type: 'screencast-frame',
|
2021-04-08 05:32:12 +08:00
|
|
|
pageId: string,
|
2021-04-08 22:59:05 +08:00
|
|
|
sha1: string,
|
|
|
|
|
width: number,
|
|
|
|
|
height: number,
|
2021-05-13 22:36:34 -07:00
|
|
|
timestamp: number,
|
2021-04-08 05:32:12 +08:00
|
|
|
};
|
|
|
|
|
|
2023-03-15 22:33:40 -07:00
|
|
|
export type BeforeActionTraceEvent = {
|
|
|
|
|
type: 'before',
|
2023-02-27 15:29:20 -08:00
|
|
|
callId: string;
|
|
|
|
|
startTime: number;
|
|
|
|
|
apiName: string;
|
|
|
|
|
class: string;
|
|
|
|
|
method: string;
|
2023-05-05 15:12:18 -07:00
|
|
|
params: Record<string, any>;
|
2023-02-27 15:29:20 -08:00
|
|
|
wallTime: number;
|
2023-03-15 22:33:40 -07:00
|
|
|
beforeSnapshot?: string;
|
2023-02-27 15:29:20 -08:00
|
|
|
stack?: StackFrame[];
|
2023-03-15 22:33:40 -07:00
|
|
|
pageId?: string;
|
2023-05-05 15:12:18 -07:00
|
|
|
parentId?: string;
|
2023-03-15 22:33:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type InputActionTraceEvent = {
|
|
|
|
|
type: 'input',
|
|
|
|
|
callId: string;
|
|
|
|
|
inputSnapshot?: string;
|
|
|
|
|
point?: Point;
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-17 10:57:28 +02:00
|
|
|
export type AfterActionTraceEventAttachment = {
|
|
|
|
|
name: string;
|
|
|
|
|
contentType: string;
|
|
|
|
|
path?: string;
|
|
|
|
|
sha1?: string;
|
|
|
|
|
base64?: string;
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-15 22:33:40 -07:00
|
|
|
export type AfterActionTraceEvent = {
|
|
|
|
|
type: 'after',
|
|
|
|
|
callId: string;
|
|
|
|
|
endTime: number;
|
|
|
|
|
afterSnapshot?: string;
|
|
|
|
|
log: string[];
|
2023-02-27 15:29:20 -08:00
|
|
|
error?: SerializedError['error'];
|
2023-08-17 10:57:28 +02:00
|
|
|
attachments?: AfterActionTraceEventAttachment[];
|
2023-02-27 15:29:20 -08:00
|
|
|
result?: any;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type EventTraceEvent = {
|
|
|
|
|
type: 'event',
|
|
|
|
|
time: number;
|
|
|
|
|
class: string;
|
|
|
|
|
method: string;
|
|
|
|
|
params: any;
|
|
|
|
|
pageId?: string;
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-19 16:13:42 -07:00
|
|
|
export type ConsoleMessageTraceEvent = {
|
2023-09-19 16:21:09 -07:00
|
|
|
type: 'console';
|
|
|
|
|
time: number;
|
|
|
|
|
pageId?: string;
|
|
|
|
|
messageType: string,
|
|
|
|
|
text: string,
|
|
|
|
|
args?: { preview: string, value: any }[],
|
|
|
|
|
location: {
|
|
|
|
|
url: string,
|
|
|
|
|
lineNumber: number,
|
|
|
|
|
columnNumber: number,
|
|
|
|
|
},
|
2020-08-28 10:51:55 -07:00
|
|
|
};
|
2020-09-18 11:54:00 -07:00
|
|
|
|
2021-04-23 20:39:09 -07:00
|
|
|
export type ResourceSnapshotTraceEvent = {
|
|
|
|
|
type: 'resource-snapshot',
|
|
|
|
|
snapshot: ResourceSnapshot,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type FrameSnapshotTraceEvent = {
|
|
|
|
|
type: 'frame-snapshot',
|
|
|
|
|
snapshot: FrameSnapshot,
|
|
|
|
|
};
|
|
|
|
|
|
2023-03-15 22:33:40 -07:00
|
|
|
export type ActionTraceEvent = {
|
|
|
|
|
type: 'action',
|
|
|
|
|
} & Omit<BeforeActionTraceEvent, 'type'>
|
|
|
|
|
& Omit<AfterActionTraceEvent, 'type'>
|
|
|
|
|
& Omit<InputActionTraceEvent, 'type'>;
|
|
|
|
|
|
2023-07-10 18:36:28 -07:00
|
|
|
export type StdioTraceEvent = {
|
|
|
|
|
type: 'stdout' | 'stderr';
|
|
|
|
|
timestamp: number;
|
|
|
|
|
text?: string;
|
|
|
|
|
base64?: string;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-18 11:54:00 -07:00
|
|
|
export type TraceEvent =
|
|
|
|
|
ContextCreatedTraceEvent |
|
2021-04-08 05:32:12 +08:00
|
|
|
ScreencastFrameTraceEvent |
|
2021-01-15 18:30:55 -08:00
|
|
|
ActionTraceEvent |
|
2023-03-15 22:33:40 -07:00
|
|
|
BeforeActionTraceEvent |
|
|
|
|
|
InputActionTraceEvent |
|
|
|
|
|
AfterActionTraceEvent |
|
2023-02-27 15:29:20 -08:00
|
|
|
EventTraceEvent |
|
2023-08-19 16:13:42 -07:00
|
|
|
ConsoleMessageTraceEvent |
|
2021-04-23 20:39:09 -07:00
|
|
|
ResourceSnapshotTraceEvent |
|
2023-07-10 18:36:28 -07:00
|
|
|
FrameSnapshotTraceEvent |
|
|
|
|
|
StdioTraceEvent;
|