Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/channelOwner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { EventEmitter } from './eventEmitter';
import { ValidationError, maybeFindValidator } from '../protocol/validator';
import { methodMetainfo } from '../utils/isomorphic/protocolMetainfo';
import { getMetainfo } from '../utils/isomorphic/protocolFormatter';
import { captureLibraryStackTrace } from './clientStackTrace';
import { stringifyStackFrames } from '../utils/isomorphic/stackTrace';

Expand Down Expand Up @@ -147,7 +147,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
get: (obj: any, prop: string | symbol) => {
if (typeof prop === 'string') {
const validator = maybeFindValidator(this._type, prop, 'Params');
const { internal } = methodMetainfo.get(this._type + '.' + prop) || {};
const { internal } = getMetainfo({ type: this._type, method: prop }) || {};
if (validator) {
return async (params: any) => {
return await this._wrapApiCall(async apiZone => {
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/server/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { SdkObject } from './instrumentation';
import { monotonicTime } from '../utils';
import { BrowserContext } from './browserContext';
import { methodMetainfo } from '../utils/isomorphic/protocolMetainfo';
import { getMetainfo } from '../utils/isomorphic/protocolFormatter';

import type { CallMetadata, InstrumentationListener } from './instrumentation';

Expand Down Expand Up @@ -125,6 +125,6 @@ function matchesLocation(metadata: CallMetadata, location: { file: string, line?
function shouldPauseBeforeStep(metadata: CallMetadata, includeInputActions: boolean): boolean {
if (metadata.internal)
return false;
const metainfo = methodMetainfo.get(metadata.type + '.' + metadata.method);
const metainfo = getMetainfo(metadata);
return !!metainfo?.pausesBeforeAction || (includeInputActions && !!metainfo?.pausesBeforeInput);
}
4 changes: 2 additions & 2 deletions packages/playwright-core/src/server/dispatchers/dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TargetClosedError, isTargetClosedError, serializeError } from '../error
import { createRootSdkObject, SdkObject } from '../instrumentation';
import { isProtocolError } from '../protocolError';
import { compressCallLog } from '../callLog';
import { methodMetainfo } from '../../utils/isomorphic/protocolMetainfo';
import { getMetainfo } from '../../utils/isomorphic/protocolFormatter';
import { Progress, ProgressController } from '../progress';

import type { CallMetadata } from '../instrumentation';
Expand Down Expand Up @@ -318,7 +318,7 @@ export class DispatcherConnection {
return;
}

const metainfo = methodMetainfo.get(dispatcher._type + '.' + method);
const metainfo = getMetainfo({ type: dispatcher._type, method });
if (metainfo?.internal) {
// For non-js ports, it is easier to detect internal calls here rather
// than generate protocol metainfo for each language.
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/server/trace/recorder/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import os from 'os';
import path from 'path';

import { Snapshotter } from './snapshotter';
import { methodMetainfo } from '../../../utils/isomorphic/protocolMetainfo';
import { getMetainfo } from '../../../utils/isomorphic/protocolFormatter';
import { assert } from '../../../utils/isomorphic/assert';
import { monotonicTime } from '../../../utils/isomorphic/time';
import { eventsHelper } from '../../utils/eventsHelper';
Expand Down Expand Up @@ -660,7 +660,7 @@ function visitTraceEvent(object: any, sha1s: Set<string>): any {
}

function shouldCaptureSnapshot(metadata: CallMetadata): boolean {
const metainfo = methodMetainfo.get(metadata.type + '.' + metadata.method);
const metainfo = getMetainfo(metadata);
return !!metainfo?.snapshot;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { methodMetainfo } from './protocolMetainfo';
import type { MethodMetainfo } from './protocolMetainfo';

export function formatProtocolParam(params: Record<string, string> | undefined, alternatives: string): string | undefined {
return _formatProtocolParam(params, alternatives)?.replaceAll('\n', '\\n');
Expand Down Expand Up @@ -63,14 +64,18 @@ function deepParam(params: Record<string, any>, name: string): string | undefine
}

export function renderTitleForCall(metadata: { title?: string, type: string, method: string, params: Record<string, string> | undefined }) {
const titleFormat = metadata.title ?? methodMetainfo.get(metadata.type + '.' + metadata.method)?.title ?? metadata.method;
const titleFormat = metadata.title ?? getMetainfo(metadata)?.title ?? metadata.method;
return titleFormat.replace(/\{([^}]+)\}/g, (fullMatch, p1) => {
return formatProtocolParam(metadata.params, p1) ?? fullMatch;
});
}

export function getMetainfo(metadata: { type: string, method: string }): MethodMetainfo | undefined {
return methodMetainfo.get(metadata.type + '.' + metadata.method);
}

export type ActionGroup = 'configuration' | 'route' | 'getter';

export function getActionGroup(metadata: { type: string, method: string }) {
return methodMetainfo.get(metadata.type + '.' + metadata.method)?.group as undefined | ActionGroup;
return getMetainfo(metadata)?.group as undefined | ActionGroup;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

// This file is generated by generate_channels.js, do not edit manually.

export const methodMetainfo = new Map<string, { internal?: boolean, title?: string, slowMo?: boolean, snapshot?: boolean, pausesBeforeInput?: boolean, pausesBeforeAction?: boolean, group?: string }>([
export type MethodMetainfo = { internal?: boolean, title?: string, slowMo?: boolean, snapshot?: boolean, pausesBeforeInput?: boolean, pausesBeforeAction?: boolean, group?: string };

export const methodMetainfo = new Map<string, MethodMetainfo>([
['APIRequestContext.fetch', { title: '{method} "{url}"', }],
['APIRequestContext.fetchResponseBody', { title: 'Get response body', group: 'getter', }],
['APIRequestContext.fetchLog', { internal: true, }],
Expand Down
5 changes: 2 additions & 3 deletions packages/trace-viewer/src/ui/actionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import type { ActionTraceEventInContext, ActionTreeItem } from '@isomorphic/trac
import type { Boundaries } from './geometry';
import { ToolbarButton } from '@web/components/toolbarButton';
import { testStatusIcon } from './testUtils';
import { methodMetainfo } from '@isomorphic/protocolMetainfo';
import { formatProtocolParam } from '@isomorphic/protocolFormatter';
import { formatProtocolParam, getMetainfo } from '@isomorphic/protocolFormatter';

export interface ActionListProps {
actions: ActionTraceEventInContext[],
Expand Down Expand Up @@ -163,7 +162,7 @@ export const renderAction = (
};

export function renderTitleForCall(action: ActionTraceEvent, sdkLanguage?: Language): { elements: React.ReactNode[], title: string } {
let titleFormat = action.title ?? methodMetainfo.get(action.class + '.' + action.method)?.title ?? action.method;
let titleFormat = action.title ?? getMetainfo({ type: action.class, method: action.method })?.title ?? action.method;
titleFormat = titleFormat.replace(/\n/g, ' ');

const elements: React.ReactNode[] = [];
Expand Down
4 changes: 3 additions & 1 deletion utils/generate_channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ for (const [name, item] of Object.entries(protocol)) {
}
}

metainfo_ts.push(`export const methodMetainfo = new Map<string, { internal?: boolean, title?: string, slowMo?: boolean, snapshot?: boolean, pausesBeforeInput?: boolean, pausesBeforeAction?: boolean, group?: string }>([
metainfo_ts.push(`export type MethodMetainfo = { internal?: boolean, title?: string, slowMo?: boolean, snapshot?: boolean, pausesBeforeInput?: boolean, pausesBeforeAction?: boolean, group?: string };

export const methodMetainfo = new Map<string, MethodMetainfo>([
${methodMetainfo.join(`,\n `)}
]);`);

Expand Down
Loading