test: verify Page.goto fails when server returns 204 (#2452)

Fixed upstream: https://crrev.com/551261
Rolled into pptr: https://github.com/GoogleChrome/puppeteer/pull/2393

Fixes #1879.
This commit is contained in:
Andrey Lushnikov 2018-04-25 20:20:11 -07:00 committed by GitHub
parent d9bb7ee8a0
commit b96815aa72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -390,6 +390,16 @@ module.exports.addTests = function({testRunner, expect, puppeteer, DeviceDescrip
});
await page.goto(server.PREFIX + '/frames/one-frame.html');
});
it('should fail when server returns 204', async({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
res.statusCode = 204;
res.end();
});
let error = null;
await page.goto(server.EMPTY_PAGE).catch(e => error = e);
expect(error).not.toBe(null);
expect(error.message).toContain('net::ERR_ABORTED');
});
it('should navigate to empty page with domcontentloaded', async({page, server}) => {
const response = await page.goto(server.EMPTY_PAGE, {waitUntil: 'domcontentloaded'});
expect(response.status()).toBe(200);