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) {
 | 
			
		||||
    this._checkNotHandled();
 | 
			
		||||
    await this._raceWithTargetClose(this._channel.abort({ errorCode }));
 | 
			
		||||
    await this._raceWithTargetClose(this._channel.abort({ requestUrl: this.request()._initializer.url, errorCode }));
 | 
			
		||||
    this._reportHandled(true);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -384,6 +384,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
 | 
			
		||||
      headers['content-length'] = String(length);
 | 
			
		||||
 | 
			
		||||
    await this._raceWithTargetClose(this._channel.fulfill({
 | 
			
		||||
      requestUrl: this.request()._initializer.url,
 | 
			
		||||
      status: statusOption || 200,
 | 
			
		||||
      headers: headersObjectToArray(headers),
 | 
			
		||||
      body,
 | 
			
		||||
@ -414,6 +415,7 @@ export class Route extends ChannelOwner<channels.RouteChannel> implements api.Ro
 | 
			
		||||
    const options = this.request()._fallbackOverridesForContinue();
 | 
			
		||||
    return await this._wrapApiCall(async () => {
 | 
			
		||||
      await this._raceWithTargetClose(this._channel.continue({
 | 
			
		||||
        requestUrl: this.request()._initializer.url,
 | 
			
		||||
        url: options.url,
 | 
			
		||||
        method: options.method,
 | 
			
		||||
        headers: options.headers ? headersObjectToArray(options.headers) : undefined,
 | 
			
		||||
 | 
			
		||||
@ -1974,6 +1974,7 @@ scheme.RouteRedirectNavigationRequestParams = tObject({
 | 
			
		||||
scheme.RouteRedirectNavigationRequestResult = tOptional(tObject({}));
 | 
			
		||||
scheme.RouteAbortParams = tObject({
 | 
			
		||||
  errorCode: tOptional(tString),
 | 
			
		||||
  requestUrl: tString,
 | 
			
		||||
});
 | 
			
		||||
scheme.RouteAbortResult = tOptional(tObject({}));
 | 
			
		||||
scheme.RouteContinueParams = tObject({
 | 
			
		||||
@ -1981,6 +1982,7 @@ scheme.RouteContinueParams = tObject({
 | 
			
		||||
  method: tOptional(tString),
 | 
			
		||||
  headers: tOptional(tArray(tType('NameValue'))),
 | 
			
		||||
  postData: tOptional(tBinary),
 | 
			
		||||
  requestUrl: tString,
 | 
			
		||||
});
 | 
			
		||||
scheme.RouteContinueResult = tOptional(tObject({}));
 | 
			
		||||
scheme.RouteFulfillParams = tObject({
 | 
			
		||||
@ -1989,6 +1991,7 @@ scheme.RouteFulfillParams = tObject({
 | 
			
		||||
  body: tOptional(tString),
 | 
			
		||||
  isBase64: tOptional(tBoolean),
 | 
			
		||||
  fetchResponseUid: tOptional(tString),
 | 
			
		||||
  requestUrl: tString,
 | 
			
		||||
});
 | 
			
		||||
scheme.RouteFulfillResult = tOptional(tObject({}));
 | 
			
		||||
scheme.ResourceTiming = tObject({
 | 
			
		||||
 | 
			
		||||
@ -460,7 +460,7 @@ export abstract class BrowserContext extends SdkObject {
 | 
			
		||||
      const internalMetadata = serverSideCallMetadata();
 | 
			
		||||
      const page = await this.newPage(internalMetadata);
 | 
			
		||||
      await page._setServerRequestInterceptor(handler => {
 | 
			
		||||
        handler.fulfill({ body: '<html></html>' }).catch(() => {});
 | 
			
		||||
        handler.fulfill({ body: '<html></html>', requestUrl: handler.request().url() }).catch(() => {});
 | 
			
		||||
        return true;
 | 
			
		||||
      });
 | 
			
		||||
      for (const origin of this._origins) {
 | 
			
		||||
@ -489,7 +489,7 @@ export abstract class BrowserContext extends SdkObject {
 | 
			
		||||
    const internalMetadata = serverSideCallMetadata();
 | 
			
		||||
    page = page || await this.newPage(internalMetadata);
 | 
			
		||||
    await page._setServerRequestInterceptor(handler => {
 | 
			
		||||
      handler.fulfill({ body: '<html></html>' }).catch(() => {});
 | 
			
		||||
      handler.fulfill({ body: '<html></html>', requestUrl: handler.request().url() }).catch(() => {});
 | 
			
		||||
      return true;
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
@ -524,7 +524,7 @@ export abstract class BrowserContext extends SdkObject {
 | 
			
		||||
        const internalMetadata = serverSideCallMetadata();
 | 
			
		||||
        const page = await this.newPage(internalMetadata);
 | 
			
		||||
        await page._setServerRequestInterceptor(handler => {
 | 
			
		||||
          handler.fulfill({ body: '<html></html>' }).catch(() => {});
 | 
			
		||||
          handler.fulfill({ body: '<html></html>', requestUrl: handler.request().url() }).catch(() => {});
 | 
			
		||||
          return true;
 | 
			
		||||
        });
 | 
			
		||||
        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> {
 | 
			
		||||
    // Used to discriminate between continue in tracing.
 | 
			
		||||
    metadata.params.requestUrl = this._object.request().url();
 | 
			
		||||
    await this._object.continue({
 | 
			
		||||
      url: params.url,
 | 
			
		||||
      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> {
 | 
			
		||||
    // Used to discriminate between fulfills in tracing.
 | 
			
		||||
    metadata.params.requestUrl = this._object.request().url();
 | 
			
		||||
    await this._object.fulfill(params);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  async abort(params: channels.RouteAbortParams, metadata: CallMetadata): Promise<void> {
 | 
			
		||||
    // Used to discriminate between abort in tracing.
 | 
			
		||||
    metadata.params.requestUrl = this._object.request().url();
 | 
			
		||||
    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);
 | 
			
		||||
      fs.promises.readFile(file).then(buffer => {
 | 
			
		||||
        route.fulfill({
 | 
			
		||||
          requestUrl: route.request().url(),
 | 
			
		||||
          status: 200,
 | 
			
		||||
          headers: [
 | 
			
		||||
            { 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 RouteAbortParams = {
 | 
			
		||||
  errorCode?: string,
 | 
			
		||||
  requestUrl: string,
 | 
			
		||||
};
 | 
			
		||||
export type RouteAbortOptions = {
 | 
			
		||||
  errorCode?: string,
 | 
			
		||||
@ -3529,6 +3530,7 @@ export type RouteContinueParams = {
 | 
			
		||||
  method?: string,
 | 
			
		||||
  headers?: NameValue[],
 | 
			
		||||
  postData?: Binary,
 | 
			
		||||
  requestUrl: string,
 | 
			
		||||
};
 | 
			
		||||
export type RouteContinueOptions = {
 | 
			
		||||
  url?: string,
 | 
			
		||||
@ -3543,6 +3545,7 @@ export type RouteFulfillParams = {
 | 
			
		||||
  body?: string,
 | 
			
		||||
  isBase64?: boolean,
 | 
			
		||||
  fetchResponseUid?: string,
 | 
			
		||||
  requestUrl: string,
 | 
			
		||||
};
 | 
			
		||||
export type RouteFulfillOptions = {
 | 
			
		||||
  status?: number,
 | 
			
		||||
 | 
			
		||||
@ -2740,6 +2740,7 @@ Route:
 | 
			
		||||
    abort:
 | 
			
		||||
      parameters:
 | 
			
		||||
        errorCode: string?
 | 
			
		||||
        requestUrl: string
 | 
			
		||||
 | 
			
		||||
    continue:
 | 
			
		||||
      parameters:
 | 
			
		||||
@ -2749,6 +2750,7 @@ Route:
 | 
			
		||||
          type: array?
 | 
			
		||||
          items: NameValue
 | 
			
		||||
        postData: binary?
 | 
			
		||||
        requestUrl: string
 | 
			
		||||
 | 
			
		||||
    fulfill:
 | 
			
		||||
      parameters:
 | 
			
		||||
@ -2760,6 +2762,7 @@ Route:
 | 
			
		||||
        body: string?
 | 
			
		||||
        isBase64: boolean?
 | 
			
		||||
        fetchResponseUid: string?
 | 
			
		||||
        requestUrl: string
 | 
			
		||||
 | 
			
		||||
ResourceTiming:
 | 
			
		||||
  type: object
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user