Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test to validate redirecting in request.respond #4106

Merged
merged 1 commit into from Mar 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion test/network.spec.js
Expand Up @@ -106,7 +106,6 @@ module.exports.addTests = function({testRunner, expect, CHROME}) {

// Load and re-load to make sure it's cached.
await page.goto(server.PREFIX + '/cached/one-style.html');
await page.waitFor(1000);
await page.reload();

expect(responses.size).toBe(2);
Expand Down Expand Up @@ -737,6 +736,25 @@ module.exports.addTests = function({testRunner, expect, CHROME}) {
expect(response.headers().foo).toBe('bar');
expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!');
});
it('should redirect', async({page, server}) => {
await page.setRequestInterception(true);
page.on('request', request => {
if (!request.url().includes('rrredirect')) {
request.continue();
return;
}
request.respond({
status: 302,
headers: {
location: server.EMPTY_PAGE,
},
});
});
const response = await page.goto(server.PREFIX + '/rrredirect');
expect(response.request().redirectChain().length).toBe(1);
expect(response.request().redirectChain()[0].url()).toBe(server.PREFIX + '/rrredirect');
expect(response.url()).toBe(server.EMPTY_PAGE);
});
it('should allow mocking binary responses', async({page, server}) => {
await page.setRequestInterception(true);
page.on('request', request => {
Expand Down