test: responseSize incorrect for 404 with content (#9328)

This commit is contained in:
Ross Wollman 2021-10-05 17:40:08 -07:00 committed by GitHub
parent 0469a7552b
commit dbc3c11b8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -167,3 +167,31 @@ for (const statusCode of [200, 401, 404, 500]) {
expect(sizes.responseBodySize).toBe(3);
});
}
it('should have correct responseBodySize for 404 with content', async ({ page, server, browserName }) => {
it.fail(browserName === 'chromium');
server.setRoute('/broken-image.png', (req, resp) => {
resp.writeHead(404);
resp.end(`<p>this should have a non-negative size</p>`);
});
server.setRoute('/page-with-404-image.html', (req, resp) => {
resp.end(`
<!DOCTYPE html>
<html>
<head><title>Page with Broken Image</title></head>
<body>
<img src="/broken-image.png" />
</body>
</html>
`);
});
const [req] = await Promise.all([
page.waitForRequest(/broken-image\.png$/),
page.goto(server.PREFIX + '/page-with-404-image.html'),
]);
const { responseBodySize } = await req.sizes();
expect(responseBodySize).toBeGreaterThanOrEqual(0);
});