fix(requestinterception): filter out "intervention" header (#3814)

Fixes #3798
This commit is contained in:
Andrey Lushnikov 2019-01-20 00:02:13 -05:00 committed by GitHub
parent c48b5749f5
commit 9fd4b67d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -651,7 +651,7 @@ class Response {
} }
helper.tracePublicAPI(Response); helper.tracePublicAPI(Response);
const IGNORED_HEADERS = new Set(['accept', 'referer', 'x-devtools-emulate-network-conditions-client-id', 'cookie', 'origin', 'content-type']); const IGNORED_HEADERS = new Set(['accept', 'referer', 'x-devtools-emulate-network-conditions-client-id', 'cookie', 'origin', 'content-type', 'intervention']);
/** /**
* @param {!Protocol.Network.Request} request * @param {!Protocol.Network.Request} request

View File

@ -266,6 +266,24 @@ module.exports.addTests = function({testRunner, expect}) {
expect(response.ok()).toBe(true); expect(response.ok()).toBe(true);
expect(response.remoteAddress().port).toBe(server.PORT); expect(response.remoteAddress().port).toBe(server.PORT);
}); });
it('should work with intervention headers', async({page, server}) => {
server.setRoute('/intervention', (req, res) => res.end(`
<script>
document.write('<script src="${server.CROSS_PROCESS_PREFIX}/intervention.js">' + '</scr' + 'ipt>');
</script>
`));
server.setRedirect('/intervention.js', '/redirect.js');
let serverRequest = null;
server.setRoute('/redirect.js', (req, res) => {
serverRequest = req;
res.end('console.log(1);');
});
await page.setRequestInterception(true);
page.on('request', request => request.continue());
await page.goto(server.PREFIX + '/intervention');
expect(serverRequest.headers.intervention).toContain('www.chromestatus.com');
});
it('should work when POST is redirected with 302', async({page, server}) => { it('should work when POST is redirected with 302', async({page, server}) => {
server.setRedirect('/rredirect', '/empty.html'); server.setRedirect('/rredirect', '/empty.html');
await page.goto(server.EMPTY_PAGE); await page.goto(server.EMPTY_PAGE);