Skip to content

Commit 80c0711

Browse files
authored
feat(firefox): roll firefox to r1137 (#3095)
1 parent 2a08883 commit 80c0711

File tree

11 files changed

+73
-24
lines changed

11 files changed

+73
-24
lines changed

browsers.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
{
99
"name": "firefox",
10-
"revision": "1134"
10+
"revision": "1137"
1111
},
1212
{
1313
"name": "webkit",

docs/api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,6 +3486,7 @@ If request gets a 'redirect' response, the request is successfully finished with
34863486
- [request.isNavigationRequest()](#requestisnavigationrequest)
34873487
- [request.method()](#requestmethod)
34883488
- [request.postData()](#requestpostdata)
3489+
- [request.postDataBuffer()](#requestpostdatabuffer)
34893490
- [request.postDataJSON()](#requestpostdatajson)
34903491
- [request.redirectedFrom()](#requestredirectedfrom)
34913492
- [request.redirectedTo()](#requestredirectedto)
@@ -3526,6 +3527,9 @@ Whether this request is driving frame's navigation.
35263527
#### request.postData()
35273528
- returns: <?[string]> Request's post body, if any.
35283529

3530+
#### request.postDataBuffer()
3531+
- returns: <?[Buffer]> Request's post body in a binary form, if any.
3532+
35293533
#### request.postDataJSON()
35303534
- returns: <?[Object]> Parsed request's body for `form-urlencoded` and JSON as a fallback if any.
35313535

src/chromium/crNetworkManager.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,14 @@ class InterceptableRequest implements network.RouteDelegate {
342342
headers,
343343
method,
344344
url,
345-
postData = null,
345+
postDataEntries = null,
346346
} = requestPausedEvent ? requestPausedEvent.request : requestWillBeSentEvent.request;
347347
const type = (requestWillBeSentEvent.type || '').toLowerCase();
348-
this.request = new network.Request(allowInterception ? this : null, frame, redirectedFrom, documentId, url, type, method, postData, headersObject(headers));
348+
let postDataBuffer = null;
349+
if (postDataEntries && postDataEntries.length && postDataEntries[0].bytes)
350+
postDataBuffer = Buffer.from(postDataEntries[0].bytes, 'base64');
351+
352+
this.request = new network.Request(allowInterception ? this : null, frame, redirectedFrom, documentId, url, type, method, postDataBuffer, headersObject(headers));
349353
}
350354

351355
async continue(overrides: types.NormalizedContinueOverrides) {

src/firefox/ffNetworkManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,11 @@ class InterceptableRequest implements network.RouteDelegate {
153153
const headers: types.Headers = {};
154154
for (const {name, value} of payload.headers)
155155
headers[name.toLowerCase()] = value;
156-
156+
let postDataBuffer = null;
157+
if (payload.postData)
158+
postDataBuffer = Buffer.from(payload.postData, 'base64');
157159
this.request = new network.Request(payload.isIntercepted ? this : null, frame, redirectedFrom ? redirectedFrom.request : null, payload.navigationId,
158-
payload.url, internalCauseToResourceType[payload.internalCause] || causeToResourceType[payload.cause] || 'other', payload.method, payload.postData || null, headers);
160+
payload.url, internalCauseToResourceType[payload.internalCause] || causeToResourceType[payload.cause] || 'other', payload.method, postDataBuffer, headers);
159161
}
160162

161163
async continue(overrides: types.NormalizedContinueOverrides) {

src/network.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ export class Request {
7878
private _url: string;
7979
private _resourceType: string;
8080
private _method: string;
81-
private _postData: string | null;
81+
private _postData: Buffer | null;
8282
private _headers: types.Headers;
8383
private _frame: frames.Frame;
8484
private _waitForResponsePromise: Promise<Response | null>;
8585
private _waitForResponsePromiseCallback: (value: Response | null) => void = () => {};
8686

8787
constructor(routeDelegate: RouteDelegate | null, frame: frames.Frame, redirectedFrom: Request | null, documentId: string | undefined,
88-
url: string, resourceType: string, method: string, postData: string | null, headers: types.Headers) {
88+
url: string, resourceType: string, method: string, postData: Buffer | null, headers: types.Headers) {
8989
assert(!url.startsWith('data:'), 'Data urls should not fire requests');
9090
assert(!(routeDelegate && redirectedFrom), 'Should not be able to intercept redirects');
9191
this._routeDelegate = routeDelegate;
@@ -121,11 +121,16 @@ export class Request {
121121
}
122122

123123
postData(): string | null {
124+
return this._postData ? this._postData.toString('utf8') : null;
125+
}
126+
127+
postDataBuffer(): Buffer | null {
124128
return this._postData;
125129
}
126130

127131
postDataJSON(): Object | null {
128-
if (!this._postData)
132+
const postData = this.postData();
133+
if (!postData)
129134
return null;
130135

131136
const contentType = this.headers()['content-type'];
@@ -134,13 +139,13 @@ export class Request {
134139

135140
if (contentType === 'application/x-www-form-urlencoded') {
136141
const entries: Record<string, string> = {};
137-
const parsed = new URLSearchParams(this._postData);
142+
const parsed = new URLSearchParams(postData);
138143
for (const [k, v] of parsed.entries())
139144
entries[k] = v;
140145
return entries;
141146
}
142147

143-
return JSON.parse(this._postData);
148+
return JSON.parse(postData);
144149
}
145150

146151
headers(): {[key: string]: string} {

src/rpc/channels.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ export type RequestInitializer = {
14001400
url: string,
14011401
resourceType: string,
14021402
method: string,
1403-
postData?: string,
1403+
postData?: Binary,
14041404
headers: {
14051405
name: string,
14061406
value: string,

src/rpc/client/network.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class Request extends ChannelOwner<RequestChannel, RequestInitializer> {
4949
private _redirectedTo: Request | null = null;
5050
_failureText: string | null = null;
5151
private _headers: types.Headers;
52+
private _postData: Buffer | null;
5253

5354
static from(request: RequestChannel): Request {
5455
return (request as any)._object;
@@ -64,6 +65,7 @@ export class Request extends ChannelOwner<RequestChannel, RequestInitializer> {
6465
if (this._redirectedFrom)
6566
this._redirectedFrom._redirectedTo = this;
6667
this._headers = headersArrayToObject(initializer.headers);
68+
this._postData = initializer.postData ? Buffer.from(initializer.postData, 'base64') : null;
6769
}
6870

6971
url(): string {
@@ -79,11 +81,16 @@ export class Request extends ChannelOwner<RequestChannel, RequestInitializer> {
7981
}
8082

8183
postData(): string | null {
82-
return this._initializer.postData || null;
84+
return this._postData ? this._postData.toString('utf8') : null;
85+
}
86+
87+
postDataBuffer(): Buffer | null {
88+
return this._postData;
8389
}
8490

8591
postDataJSON(): Object | null {
86-
if (!this._initializer.postData)
92+
const postData = this.postData();
93+
if (!postData)
8794
return null;
8895

8996
const contentType = this.headers()['content-type'];
@@ -92,13 +99,13 @@ export class Request extends ChannelOwner<RequestChannel, RequestInitializer> {
9299

93100
if (contentType === 'application/x-www-form-urlencoded') {
94101
const entries: Record<string, string> = {};
95-
const parsed = new URLSearchParams(this._initializer.postData);
102+
const parsed = new URLSearchParams(postData);
96103
for (const [k, v] of parsed.entries())
97104
entries[k] = v;
98105
return entries;
99106
}
100107

101-
return JSON.parse(this._initializer.postData);
108+
return JSON.parse(postData);
102109
}
103110

104111
headers(): types.Headers {

src/rpc/protocol.pdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ interface Request
12911291
url: string
12921292
resourceType: string
12931293
method: string
1294-
postData?: string
1294+
postData?: binary
12951295
headers: object[]
12961296
name: string
12971297
value: string

src/rpc/server/networkDispatchers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export class RequestDispatcher extends Dispatcher<Request, RequestInitializer> i
3333
}
3434

3535
private constructor(scope: DispatcherScope, request: Request) {
36-
const postData = request.postData();
36+
const postData = request.postDataBuffer();
3737
super(scope, request, 'Request', {
3838
frame: FrameDispatcher.from(scope, request.frame()),
3939
url: request.url(),
4040
resourceType: request.resourceType(),
4141
method: request.method(),
42-
postData: postData === null ? undefined : postData,
42+
postData: postData === null ? undefined : postData.toString('base64'),
4343
headers: headersObjectToArray(request.headers()),
4444
isNavigationRequest: request.isNavigationRequest(),
4545
redirectedFrom: RequestDispatcher.fromNullable(scope, request.redirectedFrom()),

src/webkit/wkInterceptableRequest.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,11 @@ export class WKInterceptableRequest implements network.RouteDelegate {
5353
this._requestId = event.requestId;
5454
this._allowInterception = allowInterception;
5555
const resourceType = event.type ? event.type.toLowerCase() : (redirectedFrom ? redirectedFrom.resourceType() : 'other');
56+
let postDataBuffer = null;
57+
if (event.request.postData)
58+
postDataBuffer = Buffer.from(event.request.postData, 'binary');
5659
this.request = new network.Request(allowInterception ? this : null, frame, redirectedFrom, documentId, event.request.url,
57-
resourceType, event.request.method, event.request.postData || null, headersObject(event.request.headers));
60+
resourceType, event.request.method, postDataBuffer, headersObject(event.request.headers));
5861
this._interceptedPromise = new Promise(f => this._interceptedCallback = f);
5962
}
6063

0 commit comments

Comments
 (0)