mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: explicitly send route's requestUrl for tracing (#21940)
This commit is contained in:
parent
054fcd39ba
commit
d4e0ef7f1a
@ -310,7 +310,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
|
|||||||
|
|
||||||
async abort(errorCode?: string) {
|
async abort(errorCode?: string) {
|
||||||
this._checkNotHandled();
|
this._checkNotHandled();
|
||||||
await this._raceWithTargetClose(this._channel.abort({ errorCode }));
|
await this._raceWithTargetClose(this._channel.abort({ requestUrl: this.request()._initializer.url, errorCode }));
|
||||||
this._reportHandled(true);
|
this._reportHandled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,6 +384,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
|
|||||||
headers['content-length'] = String(length);
|
headers['content-length'] = String(length);
|
||||||
|
|
||||||
await this._raceWithTargetClose(this._channel.fulfill({
|
await this._raceWithTargetClose(this._channel.fulfill({
|
||||||
|
requestUrl: this.request()._initializer.url,
|
||||||
status: statusOption || 200,
|
status: statusOption || 200,
|
||||||
headers: headersObjectToArray(headers),
|
headers: headersObjectToArray(headers),
|
||||||
body,
|
body,
|
||||||
@ -414,6 +415,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
|
|||||||
const options = this.request()._fallbackOverridesForContinue();
|
const options = this.request()._fallbackOverridesForContinue();
|
||||||
return await this._wrapApiCall(async () => {
|
return await this._wrapApiCall(async () => {
|
||||||
await this._raceWithTargetClose(this._channel.continue({
|
await this._raceWithTargetClose(this._channel.continue({
|
||||||
|
requestUrl: this.request()._initializer.url,
|
||||||
url: options.url,
|
url: options.url,
|
||||||
method: options.method,
|
method: options.method,
|
||||||
headers: options.headers ? headersObjectToArray(options.headers) : undefined,
|
headers: options.headers ? headersObjectToArray(options.headers) : undefined,
|
||||||
|
|||||||
@ -1974,6 +1974,7 @@ scheme.RouteRedirectNavigationRequestParams = tObject({
|
|||||||
scheme.RouteRedirectNavigationRequestResult = tOptional(tObject({}));
|
scheme.RouteRedirectNavigationRequestResult = tOptional(tObject({}));
|
||||||
scheme.RouteAbortParams = tObject({
|
scheme.RouteAbortParams = tObject({
|
||||||
errorCode: tOptional(tString),
|
errorCode: tOptional(tString),
|
||||||
|
requestUrl: tString,
|
||||||
});
|
});
|
||||||
scheme.RouteAbortResult = tOptional(tObject({}));
|
scheme.RouteAbortResult = tOptional(tObject({}));
|
||||||
scheme.RouteContinueParams = tObject({
|
scheme.RouteContinueParams = tObject({
|
||||||
@ -1981,6 +1982,7 @@ scheme.RouteContinueParams = tObject({
|
|||||||
method: tOptional(tString),
|
method: tOptional(tString),
|
||||||
headers: tOptional(tArray(tType('NameValue'))),
|
headers: tOptional(tArray(tType('NameValue'))),
|
||||||
postData: tOptional(tBinary),
|
postData: tOptional(tBinary),
|
||||||
|
requestUrl: tString,
|
||||||
});
|
});
|
||||||
scheme.RouteContinueResult = tOptional(tObject({}));
|
scheme.RouteContinueResult = tOptional(tObject({}));
|
||||||
scheme.RouteFulfillParams = tObject({
|
scheme.RouteFulfillParams = tObject({
|
||||||
@ -1989,6 +1991,7 @@ scheme.RouteFulfillParams = tObject({
|
|||||||
body: tOptional(tString),
|
body: tOptional(tString),
|
||||||
isBase64: tOptional(tBoolean),
|
isBase64: tOptional(tBoolean),
|
||||||
fetchResponseUid: tOptional(tString),
|
fetchResponseUid: tOptional(tString),
|
||||||
|
requestUrl: tString,
|
||||||
});
|
});
|
||||||
scheme.RouteFulfillResult = tOptional(tObject({}));
|
scheme.RouteFulfillResult = tOptional(tObject({}));
|
||||||
scheme.ResourceTiming = tObject({
|
scheme.ResourceTiming = tObject({
|
||||||
|
|||||||
@ -460,7 +460,7 @@ export abstract class BrowserContext extends SdkObject {
|
|||||||
const internalMetadata = serverSideCallMetadata();
|
const internalMetadata = serverSideCallMetadata();
|
||||||
const page = await this.newPage(internalMetadata);
|
const page = await this.newPage(internalMetadata);
|
||||||
await page._setServerRequestInterceptor(handler => {
|
await page._setServerRequestInterceptor(handler => {
|
||||||
handler.fulfill({ body: '<html></html>' }).catch(() => {});
|
handler.fulfill({ body: '<html></html>', requestUrl: handler.request().url() }).catch(() => {});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
for (const origin of this._origins) {
|
for (const origin of this._origins) {
|
||||||
@ -489,7 +489,7 @@ export abstract class BrowserContext extends SdkObject {
|
|||||||
const internalMetadata = serverSideCallMetadata();
|
const internalMetadata = serverSideCallMetadata();
|
||||||
page = page || await this.newPage(internalMetadata);
|
page = page || await this.newPage(internalMetadata);
|
||||||
await page._setServerRequestInterceptor(handler => {
|
await page._setServerRequestInterceptor(handler => {
|
||||||
handler.fulfill({ body: '<html></html>' }).catch(() => {});
|
handler.fulfill({ body: '<html></html>', requestUrl: handler.request().url() }).catch(() => {});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -524,7 +524,7 @@ export abstract class BrowserContext extends SdkObject {
|
|||||||
const internalMetadata = serverSideCallMetadata();
|
const internalMetadata = serverSideCallMetadata();
|
||||||
const page = await this.newPage(internalMetadata);
|
const page = await this.newPage(internalMetadata);
|
||||||
await page._setServerRequestInterceptor(handler => {
|
await page._setServerRequestInterceptor(handler => {
|
||||||
handler.fulfill({ body: '<html></html>' }).catch(() => {});
|
handler.fulfill({ body: '<html></html>', requestUrl: handler.request().url() }).catch(() => {});
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
for (const originState of state.origins) {
|
for (const originState of state.origins) {
|
||||||
|
|||||||
@ -127,7 +127,6 @@ export class RouteDispatcher extends Dispatcher<Route, channels.RouteChannel, Re
|
|||||||
|
|
||||||
async continue(params: channels.RouteContinueParams, metadata: CallMetadata): Promise<channels.RouteContinueResult> {
|
async continue(params: channels.RouteContinueParams, metadata: CallMetadata): Promise<channels.RouteContinueResult> {
|
||||||
// Used to discriminate between continue in tracing.
|
// Used to discriminate between continue in tracing.
|
||||||
metadata.params.requestUrl = this._object.request().url();
|
|
||||||
await this._object.continue({
|
await this._object.continue({
|
||||||
url: params.url,
|
url: params.url,
|
||||||
method: params.method,
|
method: params.method,
|
||||||
@ -138,13 +137,11 @@ export class RouteDispatcher extends Dispatcher<Route, channels.RouteChannel, Re
|
|||||||
|
|
||||||
async fulfill(params: channels.RouteFulfillParams, metadata: CallMetadata): Promise<void> {
|
async fulfill(params: channels.RouteFulfillParams, metadata: CallMetadata): Promise<void> {
|
||||||
// Used to discriminate between fulfills in tracing.
|
// Used to discriminate between fulfills in tracing.
|
||||||
metadata.params.requestUrl = this._object.request().url();
|
|
||||||
await this._object.fulfill(params);
|
await this._object.fulfill(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async abort(params: channels.RouteAbortParams, metadata: CallMetadata): Promise<void> {
|
async abort(params: channels.RouteAbortParams, metadata: CallMetadata): Promise<void> {
|
||||||
// Used to discriminate between abort in tracing.
|
// Used to discriminate between abort in tracing.
|
||||||
metadata.params.requestUrl = this._object.request().url();
|
|
||||||
await this._object.abort(params.errorCode || 'failed');
|
await this._object.abort(params.errorCode || 'failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,7 @@ export class RecorderApp extends EventEmitter implements IRecorderApp {
|
|||||||
const file = require.resolve('../../webpack/recorder/' + uri);
|
const file = require.resolve('../../webpack/recorder/' + uri);
|
||||||
fs.promises.readFile(file).then(buffer => {
|
fs.promises.readFile(file).then(buffer => {
|
||||||
route.fulfill({
|
route.fulfill({
|
||||||
|
requestUrl: route.request().url(),
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: [
|
headers: [
|
||||||
{ name: 'Content-Type', value: mime.getType(path.extname(file)) || 'application/octet-stream' }
|
{ name: 'Content-Type', value: mime.getType(path.extname(file)) || 'application/octet-stream' }
|
||||||
|
|||||||
@ -3519,6 +3519,7 @@ export type RouteRedirectNavigationRequestOptions = {
|
|||||||
export type RouteRedirectNavigationRequestResult = void;
|
export type RouteRedirectNavigationRequestResult = void;
|
||||||
export type RouteAbortParams = {
|
export type RouteAbortParams = {
|
||||||
errorCode?: string,
|
errorCode?: string,
|
||||||
|
requestUrl: string,
|
||||||
};
|
};
|
||||||
export type RouteAbortOptions = {
|
export type RouteAbortOptions = {
|
||||||
errorCode?: string,
|
errorCode?: string,
|
||||||
@ -3529,6 +3530,7 @@ export type RouteContinueParams = {
|
|||||||
method?: string,
|
method?: string,
|
||||||
headers?: NameValue[],
|
headers?: NameValue[],
|
||||||
postData?: Binary,
|
postData?: Binary,
|
||||||
|
requestUrl: string,
|
||||||
};
|
};
|
||||||
export type RouteContinueOptions = {
|
export type RouteContinueOptions = {
|
||||||
url?: string,
|
url?: string,
|
||||||
@ -3543,6 +3545,7 @@ export type RouteFulfillParams = {
|
|||||||
body?: string,
|
body?: string,
|
||||||
isBase64?: boolean,
|
isBase64?: boolean,
|
||||||
fetchResponseUid?: string,
|
fetchResponseUid?: string,
|
||||||
|
requestUrl: string,
|
||||||
};
|
};
|
||||||
export type RouteFulfillOptions = {
|
export type RouteFulfillOptions = {
|
||||||
status?: number,
|
status?: number,
|
||||||
|
|||||||
@ -2740,6 +2740,7 @@ Route:
|
|||||||
abort:
|
abort:
|
||||||
parameters:
|
parameters:
|
||||||
errorCode: string?
|
errorCode: string?
|
||||||
|
requestUrl: string
|
||||||
|
|
||||||
continue:
|
continue:
|
||||||
parameters:
|
parameters:
|
||||||
@ -2749,6 +2750,7 @@ Route:
|
|||||||
type: array?
|
type: array?
|
||||||
items: NameValue
|
items: NameValue
|
||||||
postData: binary?
|
postData: binary?
|
||||||
|
requestUrl: string
|
||||||
|
|
||||||
fulfill:
|
fulfill:
|
||||||
parameters:
|
parameters:
|
||||||
@ -2760,6 +2762,7 @@ Route:
|
|||||||
body: string?
|
body: string?
|
||||||
isBase64: boolean?
|
isBase64: boolean?
|
||||||
fetchResponseUid: string?
|
fetchResponseUid: string?
|
||||||
|
requestUrl: string
|
||||||
|
|
||||||
ResourceTiming:
|
ResourceTiming:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user