Skip to content

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

fix: allow binary response interception (#9236)

Max Schmitta1d0878fa10a
diff --git a/src/server/network.ts b/src/server/network.ts
index 9bd1bbb585..3b3fd9bdc4 100644
--- a/src/server/network.ts
+++ b/src/server/network.ts
@@ -231,11 +231,11 @@ export class Route extends SdkObject {
const context = this._request.frame()._page._browserContext;
const buffer = context.fetchRequest.fetchResponses.get(overrides.fetchResponseUid) || FetchRequest.findResponseBody(overrides.fetchResponseUid);
assert(buffer, 'Fetch response has been disposed');
- body = buffer.toString('utf8');
- isBase64 = false;
+ body = buffer.toString('base64');
+ isBase64 = true;
} else if (this._response && overrides.useInterceptedResponseBody) {
- body = (await this._delegate.responseBody()).toString('utf8');
- isBase64 = false;
+ body = (await this._delegate.responseBody()).toString('base64');
+ isBase64 = true;
} else {
body = '';
isBase64 = false;
diff --git a/tests/download.spec.ts b/tests/download.spec.ts
index 5925c0295c..cc4f7be0a2 100644
--- a/tests/download.spec.ts
+++ b/tests/download.spec.ts
@@ -596,8 +596,8 @@ it('should be able to download a PDF file', async ({ browser, server, asset }) =
await page.close();
});
-it('should be able to download a inline PDF file', async ({ browser, server, asset }) => {
- it.fixme();
+it('should be able to download a inline PDF file', async ({ browser, server, asset, browserName }) => {
+ it.fixme(browserName === 'webkit');
const page = await browser.newPage({ acceptDownloads: true });
await page.goto(server.EMPTY_PAGE);
await page.route('**/empty.pdf', async route => {