api: make request.postData() return null instead of undefined (#1366)

This commit is contained in:
Dmitry Gozman 2020-03-12 16:53:04 -07:00 committed by GitHub
parent be83cba409
commit 3fa4255bc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 11 deletions

View file

@ -3365,7 +3365,7 @@ Whether this request is driving frame's navigation.
- returns: <[string]> Request's method (GET, POST, etc.)
#### request.postData()
- returns: <[string]> Request's post body, if any.
- returns: <?[string]> Request's post body, if any.
#### request.redirectChain()
- returns: <[Array]<[Request]>>

View file

@ -255,7 +255,7 @@ class InterceptableRequest implements network.RequestDelegate {
this._documentId = documentId;
this.request = new network.Request(allowInterception ? this : null, frame, redirectChain, documentId,
event.request.url, (event.type || '').toLowerCase(), event.request.method, event.request.postData, headersObject(event.request.headers));
event.request.url, (event.type || '').toLowerCase(), event.request.method, event.request.postData || null, headersObject(event.request.headers));
}
async continue(overrides: { method?: string; headers?: network.Headers; postData?: string } = {}) {

View file

@ -155,7 +155,7 @@ class InterceptableRequest implements network.RequestDelegate {
headers[name.toLowerCase()] = value;
this.request = new network.Request(payload.isIntercepted ? this : null, frame, redirectChain, payload.navigationId,
payload.url, causeToResourceType[payload.cause] || 'other', payload.method, payload.postData, headers);
payload.url, causeToResourceType[payload.cause] || 'other', payload.method, payload.postData || null, headers);
}
async continue(overrides: { method?: string; headers?: network.Headers; postData?: string }) {

View file

@ -105,7 +105,7 @@ export class Request {
private _url: string;
private _resourceType: string;
private _method: string;
private _postData: string | undefined;
private _postData: string | null;
private _headers: Headers;
private _frame: frames.Frame;
private _waitForResponsePromise: Promise<Response>;
@ -115,7 +115,7 @@ export class Request {
private _interceptionHandled = false;
constructor(delegate: RequestDelegate | null, frame: frames.Frame, redirectChain: Request[], documentId: string | undefined,
url: string, resourceType: string, method: string, postData: string | undefined, headers: Headers) {
url: string, resourceType: string, method: string, postData: string | null, headers: Headers) {
assert(!url.startsWith('data:'), 'Data urls should not fire requests');
this._delegate = delegate;
this._frame = frame;
@ -151,7 +151,7 @@ export class Request {
return this._method;
}
postData(): string | undefined {
postData(): string | null {
return this._postData;
}

View file

@ -50,7 +50,7 @@ export class WKInterceptableRequest implements network.RequestDelegate {
this._session = session;
this._requestId = event.requestId;
this.request = new network.Request(allowInterception ? this : null, frame, redirectChain, documentId, event.request.url,
event.type ? event.type.toLowerCase() : 'Unknown', event.request.method, event.request.postData, headersObject(event.request.headers));
event.type ? event.type.toLowerCase() : 'Unknown', event.request.method, event.request.postData || null, headersObject(event.request.headers));
this._interceptedPromise = new Promise(f => this._interceptedCallback = f);
}

View file

@ -376,7 +376,7 @@ module.exports.describe = function({testRunner, expect, playwright, CHROMIUM, FF
expect(request.url()).toContain('empty.html');
expect(request.headers()['user-agent']).toBeTruthy();
expect(request.method()).toBe('GET');
expect(request.postData()).toBe(undefined);
expect(request.postData()).toBe(null);
expect(request.isNavigationRequest()).toBe(true);
expect(request.resourceType()).toBe('document');
expect(request.frame() === page.mainFrame()).toBe(true);

View file

@ -36,7 +36,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
expect(request.url()).toContain('empty.html');
expect(request.headers()['user-agent']).toBeTruthy();
expect(request.method()).toBe('GET');
expect(request.postData()).toBe(undefined);
expect(request.postData()).toBe(null);
expect(request.isNavigationRequest()).toBe(true);
expect(request.resourceType()).toBe('document');
expect(request.frame() === page.mainFrame()).toBe(true);
@ -586,7 +586,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
expect(request.url()).toContain('empty.html');
expect(request.headers()['user-agent']).toBeTruthy();
expect(request.method()).toBe('GET');
expect(request.postData()).toBe(undefined);
expect(request.postData()).toBe(null);
expect(request.isNavigationRequest()).toBe(true);
expect(request.resourceType()).toBe('document');
expect(request.frame() === page.mainFrame()).toBe(true);

View file

@ -112,7 +112,7 @@ module.exports.describe = function({testRunner, expect, MAC, WIN, FFOX, CHROMIUM
});
it('should be |undefined| when there is no post data', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE);
expect(response.request().postData()).toBe(undefined);
expect(response.request().postData()).toBe(null);
});
});