mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-06 11:18:20 +03:00
test: intercepted requests bypass disk cache (#30011)
Reference https://github.com/microsoft/playwright/issues/30000
This commit is contained in:
parent
48ccc9cbcd
commit
69f2ae1e4d
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user