test: add test for firefox proxy failure (#10853)

References #10095
This commit is contained in:
Andrey Lushnikov 2021-12-10 13:12:14 -08:00 committed by GitHub
parent 2d386ee8e7
commit c0aecbfd57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,6 +94,39 @@ it('should authenticate', async ({ browserType, server }) => {
await browser.close(); await browser.close();
}); });
it('should work with authenticate followed by redirect', async ({ browserName, browserType, server }) => {
it.fixme(browserName === 'firefox', 'https://github.com/microsoft/playwright/issues/10095');
function hasAuth(req, res) {
const auth = req.headers['proxy-authorization'];
if (!auth) {
res.writeHead(407, 'Proxy Authentication Required', {
'Proxy-Authenticate': 'Basic realm="Access to internal site"'
});
res.end();
return false;
}
return true;
}
server.setRoute('/page1.html', async (req, res) => {
if (!hasAuth(req, res))
return;
res.writeHead(302, { location: '/page2.html' });
res.end();
});
server.setRoute('/page2.html', async (req, res) => {
if (!hasAuth(req, res))
return;
res.end('<html><title>Served by the proxy</title></html>');
});
const browser = await browserType.launch({
proxy: { server: `localhost:${server.PORT}`, username: 'user', password: 'secret' }
});
const page = await browser.newPage();
await page.goto('http://non-existent.com/page1.html');
expect(await page.title()).toBe('Served by the proxy');
await browser.close();
});
it('should exclude patterns', async ({ browserType, server, browserName, headless }) => { it('should exclude patterns', async ({ browserType, server, browserName, headless }) => {
it.fixme(browserName === 'chromium' && !headless, 'Chromium headed crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame.'); it.fixme(browserName === 'chromium' && !headless, 'Chromium headed crashes with CHECK(!in_frame_tree_) in RenderFrameImpl::OnDeleteFrame.');