From 9fd4b67d0c6597f32a5907f241f081add0d492d3 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Sun, 20 Jan 2019 00:02:13 -0500 Subject: [PATCH] fix(requestinterception): filter out "intervention" header (#3814) Fixes #3798 --- lib/NetworkManager.js | 2 +- test/network.spec.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/NetworkManager.js b/lib/NetworkManager.js index be73442a400..3e63ce887ee 100644 --- a/lib/NetworkManager.js +++ b/lib/NetworkManager.js @@ -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 diff --git a/test/network.spec.js b/test/network.spec.js index a2d37440c19..693d05116e8 100644 --- a/test/network.spec.js +++ b/test/network.spec.js @@ -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(` + + `)); + 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);