diff --git a/tests/page/page-network-response.spec.ts b/tests/page/page-network-response.spec.ts index 0c698beebd..b856362fa6 100644 --- a/tests/page/page-network-response.spec.ts +++ b/tests/page/page-network-response.spec.ts @@ -347,3 +347,55 @@ it('should return body for prefetch script', async ({ page, server, browserName const body = await response.body(); expect(body.toString()).toBe('// Scripts will be pre-fetched'); }); + +it('should bypass disk cache when interception is enabled', async ({ page, server, browserName }) => { + it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30000' }); + it.fixme(browserName === 'firefox', 'Returns cached response.'); + await page.goto(server.PREFIX + '/frames/one-frame.html'); + await page.route('**/api*', route => route.continue()); + { + const requests = []; + server.setRoute('/api', (req, res) => { + requests.push(req); + res.statusCode = 200; + res.setHeader('content-type', 'text/plain'); + res.setHeader('cache-control', 'public, max-age=31536000'); + res.end('Hello'); + }); + for (let i = 0; i < 3; i++) { + await it.step(`main frame iteration ${i}`, async () => { + const respPromise = page.waitForResponse('**/api'); + await page.evaluate(async () => { + const response = await fetch('/api'); + return response.status; + }); + const response = await respPromise; + expect(response.status()).toBe(200); + expect(requests.length).toBe(i + 1); + }); + } + } + + { + const requests = []; + server.setRoute('/frame/api', (req, res) => { + requests.push(req); + res.statusCode = 200; + res.setHeader('content-type', 'text/plain'); + res.setHeader('cache-control', 'public, max-age=31536000'); + res.end('Hello'); + }); + for (let i = 0; i < 3; i++) { + await it.step(`subframe iteration ${i}`, async () => { + const respPromise = page.waitForResponse('**/frame/api'); + await page.frame({ url: '**/frame.html' }).evaluate(async () => { + const response = await fetch('/frame/api'); + return response.status; + }); + const response = await respPromise; + expect(response.status()).toBe(200); + expect(requests.length).toBe(i + 1); + }); + } + } +});