Skip to content

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

fix(webkit): deduce response mime type from content-type (#9264)

Yury Semikhatsky1b4adfb91679
diff --git a/src/server/webkit/wkInterceptableRequest.ts b/src/server/webkit/wkInterceptableRequest.ts
index 8aff250bb2..2ea1c2a359 100644
--- a/src/server/webkit/wkInterceptableRequest.ts
+++ b/src/server/webkit/wkInterceptableRequest.ts
@@ -130,7 +130,7 @@ export class WKRouteImpl implements network.RouteDelegate {
// In certain cases, protocol will return error if the request was already canceled
// or the page was closed. We should tolerate these errors.
let mimeType = response.isBase64 ? 'application/octet-stream' : 'text/plain';
- const headers = headersArrayToObject(response.headers, false /* lowerCase */);
+ const headers = headersArrayToObject(response.headers, true /* lowerCase */);
const contentType = headers['content-type'];
if (contentType)
mimeType = contentType.split(';')[0].trim();
diff --git a/tests/page/page-request-fulfill.spec.ts b/tests/page/page-request-fulfill.spec.ts
index 7f884d720e..90cc071c8e 100644
--- a/tests/page/page-request-fulfill.spec.ts
+++ b/tests/page/page-request-fulfill.spec.ts
@@ -225,7 +225,7 @@ it('should fulfill with fetch result and overrides', async ({ page, server, isEl
response,
status: 201,
headers: {
- ...response.headers(),
+ 'Content-Type': 'application/json', // Case matters for the tested behavior
'foo': 'bar'
}
});