diff --git a/test/features/requestinterception.spec.js b/test/features/interception.spec.js similarity index 91% rename from test/features/requestinterception.spec.js rename to test/features/interception.spec.js index b342b90874..b6bdee8e2e 100644 --- a/test/features/requestinterception.spec.js +++ b/test/features/interception.spec.js @@ -570,6 +570,63 @@ module.exports.addTests = function({testRunner, expect, FFOX, CHROME, WEBKIT}) { }); }); + describe.skip(FFOX)('Interception.authenticate', function() { + it('should work', async({page, server}) => { + server.setAuth('/empty.html', 'user', 'pass'); + let response = await page.goto(server.EMPTY_PAGE); + expect(response.status()).toBe(401); + await page.interception.authenticate({ + username: 'user', + password: 'pass' + }); + response = await page.reload(); + expect(response.status()).toBe(200); + }); + it('should fail if wrong credentials', async({page, server}) => { + // Use unique user/password since Chrome caches credentials per origin. + server.setAuth('/empty.html', 'user2', 'pass2'); + await page.interception.authenticate({ + username: 'foo', + password: 'bar' + }); + const response = await page.goto(server.EMPTY_PAGE); + expect(response.status()).toBe(401); + }); + it('should allow disable authentication', async({page, server}) => { + // Use unique user/password since Chrome caches credentials per origin. + server.setAuth('/empty.html', 'user3', 'pass3'); + await page.interception.authenticate({ + username: 'user3', + password: 'pass3' + }); + let response = await page.goto(server.EMPTY_PAGE); + expect(response.status()).toBe(200); + await page.interception.authenticate(null); + // Navigate to a different origin to bust Chrome's credential caching. + response = await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html'); + expect(response.status()).toBe(401); + }); + }); + + + describe.skip(FFOX)('Interception.setOfflineMode', function() { + it('should work', async({page, server}) => { + await page.interception.setOfflineMode(true); + let error = null; + await page.goto(server.EMPTY_PAGE).catch(e => error = e); + expect(error).toBeTruthy(); + await page.interception.setOfflineMode(false); + const response = await page.reload(); + expect(response.status()).toBe(200); + }); + it('should emulate navigator.onLine', async({page, server}) => { + expect(await page.evaluate(() => window.navigator.onLine)).toBe(true); + await page.interception.setOfflineMode(true); + expect(await page.evaluate(() => window.navigator.onLine)).toBe(false); + await page.interception.setOfflineMode(false); + expect(await page.evaluate(() => window.navigator.onLine)).toBe(true); + }); + }); }; /** diff --git a/test/network.spec.js b/test/network.spec.js index ae1cad06d3..1647b0bf97 100644 --- a/test/network.spec.js +++ b/test/network.spec.js @@ -356,44 +356,5 @@ module.exports.addTests = function({testRunner, expect, FFOX, CHROME, WEBKIT}) { expect(error.message).toBe('Expected value of header "foo" to be String, but "number" is found.'); }); }); - - // FIXME: WebKit doesn't support network interception. - describe.skip(FFOX || WEBKIT)('Interception.authenticate', function() { - it('should work', async({page, server}) => { - server.setAuth('/empty.html', 'user', 'pass'); - let response = await page.goto(server.EMPTY_PAGE); - expect(response.status()).toBe(401); - await page.interception.authenticate({ - username: 'user', - password: 'pass' - }); - response = await page.reload(); - expect(response.status()).toBe(200); - }); - it('should fail if wrong credentials', async({page, server}) => { - // Use unique user/password since Chrome caches credentials per origin. - server.setAuth('/empty.html', 'user2', 'pass2'); - await page.interception.authenticate({ - username: 'foo', - password: 'bar' - }); - const response = await page.goto(server.EMPTY_PAGE); - expect(response.status()).toBe(401); - }); - it('should allow disable authentication', async({page, server}) => { - // Use unique user/password since Chrome caches credentials per origin. - server.setAuth('/empty.html', 'user3', 'pass3'); - await page.interception.authenticate({ - username: 'user3', - password: 'pass3' - }); - let response = await page.goto(server.EMPTY_PAGE); - expect(response.status()).toBe(200); - await page.interception.authenticate(null); - // Navigate to a different origin to bust Chrome's credential caching. - response = await page.goto(server.CROSS_PROCESS_PREFIX + '/empty.html'); - expect(response.status()).toBe(401); - }); - }); }; diff --git a/test/page.spec.js b/test/page.spec.js index cebe1c39de..f3521ed20c 100644 --- a/test/page.spec.js +++ b/test/page.spec.js @@ -166,25 +166,6 @@ module.exports.addTests = function({testRunner, expect, headless, playwright, FF }); }); - describe.skip(FFOX || WEBKIT)('Interception.setOfflineMode', function() { - it('should work', async({page, server}) => { - await page.interception.setOfflineMode(true); - let error = null; - await page.goto(server.EMPTY_PAGE).catch(e => error = e); - expect(error).toBeTruthy(); - await page.interception.setOfflineMode(false); - const response = await page.reload(); - expect(response.status()).toBe(200); - }); - it('should emulate navigator.onLine', async({page, server}) => { - expect(await page.evaluate(() => window.navigator.onLine)).toBe(true); - await page.interception.setOfflineMode(true); - expect(await page.evaluate(() => window.navigator.onLine)).toBe(false); - await page.interception.setOfflineMode(false); - expect(await page.evaluate(() => window.navigator.onLine)).toBe(true); - }); - }); - describe('Page.Events.Console', function() { it('should work', async({page, server}) => { let message = null; diff --git a/test/playwright.spec.js b/test/playwright.spec.js index 94e83a14fb..89cd5dfdd0 100644 --- a/test/playwright.spec.js +++ b/test/playwright.spec.js @@ -162,7 +162,7 @@ module.exports.addTests = ({testRunner, product, playwrightPath}) => { if (CHROME || FFOX) { require('./features/accessibility.spec.js').addTests(testOptions); require('./features/permissions.spec.js').addTests(testOptions); - require('./features/requestinterception.spec.js').addTests(testOptions); + require('./features/interception.spec.js').addTests(testOptions); } });