diff --git a/tests/browsercontext-proxy.spec.ts b/tests/browsercontext-proxy.spec.ts index e51e58b642..df20765ed5 100644 --- a/tests/browsercontext-proxy.spec.ts +++ b/tests/browsercontext-proxy.spec.ts @@ -21,11 +21,17 @@ it.use({ proxy: { server: 'per-context' } }); it('should throw for missing global proxy on Chromium Windows', async ({ browserName, platform, browserType, browserOptions, server }) => { it.skip(browserName !== 'chromium' || platform !== 'win32'); - delete browserOptions.proxy; - const browser = await browserType.launch(browserOptions); - const error = await browser.newContext({ proxy: { server: `localhost:${server.PORT}` } }).catch(e => e); - expect(error.toString()).toContain('Browser needs to be launched with the global proxy'); - await browser.close(); + let browser; + try { + browser = await browserType.launch({ + ...browserOptions, + proxy: undefined, + }); + const error = await browser.newContext({ proxy: { server: `localhost:${server.PORT}` } }).catch(e => e); + expect(error.toString()).toContain('Browser needs to be launched with the global proxy'); + } finally { + await browser.close(); + } }); it('should work when passing the proxy only on the context level', async ({browserName, platform, browserType, browserOptions, contextOptions, server}) => { @@ -36,17 +42,23 @@ it('should work when passing the proxy only on the context level', async ({brows server.setRoute('/target.html', async (req, res) => { res.end('Served by the proxy'); }); - delete browserOptions.proxy; - const browser = await browserType.launch(browserOptions); - const context = await browser.newContext({ - ...contextOptions, - proxy: { server: `localhost:${server.PORT}` } - }); + let browser; + try { + browser = await browserType.launch({ + ...browserOptions, + proxy: undefined, + }); + const context = await browser.newContext({ + ...contextOptions, + proxy: { server: `localhost:${server.PORT}` } + }); - const page = await context.newPage(); - await page.goto('http://non-existent.com/target.html'); - expect(await page.title()).toBe('Served by the proxy'); - await browser.close(); + const page = await context.newPage(); + await page.goto('http://non-existent.com/target.html'); + expect(await page.title()).toBe('Served by the proxy'); + } finally { + await browser.close(); + } }); it('should throw for bad server value', async ({ contextFactory }) => { diff --git a/tests/har.spec.ts b/tests/har.spec.ts index 5d839ab823..9ee3747097 100644 --- a/tests/har.spec.ts +++ b/tests/har.spec.ts @@ -381,6 +381,7 @@ it('should have connection details', async ({ contextFactory, server, browserNam it('should have security details', async ({ contextFactory, httpsServer, browserName, platform }, testInfo) => { it.fail(browserName === 'webkit' && platform === 'linux', 'https://github.com/microsoft/playwright/issues/6759'); + it.fail(browserName === 'webkit' && platform === 'win32'); const { page, getLog } = await pageWithHar(contextFactory, testInfo); await page.goto(httpsServer.EMPTY_PAGE); @@ -388,9 +389,7 @@ it('should have security details', async ({ contextFactory, httpsServer, browser const { serverIPAddress, _serverPort: port, _securityDetails: securityDetails } = log.entries[0]; expect(serverIPAddress).toMatch(/^127\.0\.0\.1|\[::1\]/); expect(port).toBe(httpsServer.PORT); - if (browserName === 'webkit' && platform === 'win32') - expect(securityDetails).toEqual({subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: -1}); - else if (browserName === 'webkit') + if (browserName === 'webkit' && platform === 'darwin') expect(securityDetails).toEqual({protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863}); else expect(securityDetails).toEqual({issuer: 'puppeteer-tests', protocol: 'TLS 1.3', subjectName: 'puppeteer-tests', validFrom: 1550084863, validTo: 33086084863});