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
36 changes: 28 additions & 8 deletions browser_patches/firefox/juggler/NetworkObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class NetworkRequest {
responseStart: this.httpChannel.responseStartTime,
};

const { status, statusText, headers } = responseHead(this.httpChannel, opt_statusCode, opt_statusText);
const { status, statusText, headers } = responseHead(this.httpChannel, fromCache, opt_statusCode, opt_statusText);
if (redirectStatus.includes(status) && this._overriddenHeadersForRedirect)
this._overriddenHeadersForRedirect = filterHeadersForRedirect(this._overriddenHeadersForRedirect, this.httpChannel.requestMethod, status);
let remoteIPAddress = undefined;
Expand Down Expand Up @@ -968,19 +968,39 @@ class ResponseStorage {
}
}

function responseHead(httpChannel, opt_statusCode, opt_statusText) {
const headers = [];
function responseHead(httpChannel, fromCache, opt_statusCode, opt_statusText) {
let headers = [];
let status = opt_statusCode || 0;
let statusText = opt_statusText || '';
try {
status = httpChannel.responseStatus;
statusText = httpChannel.responseStatusText;
httpChannel.visitResponseHeaders({
visitHeader: (name, value) => headers.push({name, value}),
});
} catch (e) {
// Response headers, status and/or statusText are not available
// when redirect did not actually hit the network.
if (e.result !== Cr.NS_ERROR_NOT_AVAILABLE)
console.error('Failed to read response status', e);
return { status, statusText, headers };
}
const visitor = {
visitHeader: (name, value) => headers.push({name, value}),
};
// Responses are cached after cookies and authentication headers are revalidated/pruned.
// As such, do not use the original headers as that may not reflect what was actually used.
if (!fromCache) {
try {
httpChannel.visitOriginalResponseHeaders(visitor);
} catch (e) {
if (e.result !== Cr.NS_ERROR_NOT_AVAILABLE)
console.error('Failed to read original response headers', e);
headers = [];
}
}
if (!headers.length) {
try {
httpChannel.visitResponseHeaders(visitor);
} catch (e) {
if (e.result !== Cr.NS_ERROR_NOT_AVAILABLE)
console.error('Failed to read response headers', e);
}
}
return { status, statusText, headers };
}
Expand Down
2 changes: 1 addition & 1 deletion browser_patches/firefox/juggler/content/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function initialize(browsingContext, docShell) {
for (const { worldName, name, script } of [...contextCrossProcessCookie.bindings, ...pageCrossProcessCookie.bindings])
data.frameTree.addBinding(worldName, name, script);
data.frameTree.setInitScripts([...contextCrossProcessCookie.initScripts, ...pageCrossProcessCookie.initScripts]);
data.channel = new SimpleChannel('', 'process-' + Services.appinfo.processID);
data.channel = new SimpleChannel('', 'process-' + Services.appinfo.processID + '-' + helper.generateId());
data.pageAgent = new PageAgent(data.channel, data.frameTree);
docShell.fileInputInterceptionEnabled = !!pageCrossProcessCookie.interceptFileChooserDialog;

Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
{
"name": "firefox",
"revision": "1549",
"revision": "1551",
"installByDefault": true,
"browserVersion": "156.0",
"title": "Firefox"
Expand Down
Loading