Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(firefox): roll to r1551 (#42843)

microsoft-playwright-automation[bot]e5d880b05f9a
diff --git a/browser_patches/firefox/juggler/NetworkObserver.js b/browser_patches/firefox/juggler/NetworkObserver.js
index bc4428b996..e2e4f1993e 100644
--- a/browser_patches/firefox/juggler/NetworkObserver.js
+++ b/browser_patches/firefox/juggler/NetworkObserver.js
@@ -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;
@@ -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 };
}
diff --git a/browser_patches/firefox/juggler/content/main.js b/browser_patches/firefox/juggler/content/main.js
index 8028692f87..5842ed8fb2 100644
--- a/browser_patches/firefox/juggler/content/main.js
+++ b/browser_patches/firefox/juggler/content/main.js
@@ -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;
diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json
index 45dd907b98..94d8286f26 100644
--- a/packages/playwright-core/browsers.json
+++ b/packages/playwright-core/browsers.json
@@ -17,7 +17,7 @@
},
{
"name": "firefox",
- "revision": "1549",
+ "revision": "1551",
"installByDefault": true,
"browserVersion": "156.0",
"title": "Firefox"