mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix(requestinterception): filter out "intervention" header (#3814)
Fixes #3798
This commit is contained in:
parent
c48b5749f5
commit
9fd4b67d0c
@ -651,7 +651,7 @@ class 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
|
||||
|
@ -266,6 +266,24 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
expect(response.ok()).toBe(true);
|
||||
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}) => {
|
||||
server.setRedirect('/rredirect', '/empty.html');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
|
Loading…
Reference in New Issue
Block a user