fix(firefox): disable cache when request interception is enabled (#30113)

Fixes #30000
This commit is contained in:
Andrey Lushnikov 2024-03-28 10:25:37 -07:00 committed by GitHub
parent a440800403
commit 4781b3c3a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 8 deletions

View File

@ -366,7 +366,10 @@ export class FFBrowserContext extends BrowserContext {
}
async doUpdateRequestInterception(): Promise<void> {
await this._browser.session.send('Browser.setRequestInterception', { browserContextId: this._browserContextId, enabled: !!this._requestInterceptor });
await Promise.all([
this._browser.session.send('Browser.setRequestInterception', { browserContextId: this._browserContextId, enabled: !!this._requestInterceptor }),
this._browser.session.send('Browser.setCacheDisabled', { browserContextId: this._browserContextId, cacheDisabled: !!this._requestInterceptor }),
]);
}
onClosePersistent() {}

View File

@ -50,7 +50,10 @@ export class FFNetworkManager {
}
async setRequestInterception(enabled: boolean) {
await this._session.send('Network.setRequestInterception', { enabled });
await Promise.all([
this._session.send('Network.setRequestInterception', { enabled }),
this._session.send('Page.setCacheDisabled', { cacheDisabled: enabled }),
]);
}
_onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload) {

View File

@ -348,9 +348,8 @@ it('should return body for prefetch script', async ({ page, server, browserName
expect(body.toString()).toBe('// Scripts will be pre-fetched');
});
it('should bypass disk cache when page interception is enabled', async ({ page, server, browserName }) => {
it('should bypass disk cache when page interception is enabled', async ({ page, server }) => {
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());
{
@ -400,9 +399,8 @@ it('should bypass disk cache when page interception is enabled', async ({ page,
}
});
it('should bypass disk cache when context interception is enabled', async ({ page, server, browserName }) => {
it('should bypass disk cache when context interception is enabled', async ({ page, server }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30000' });
it.fixme(browserName === 'firefox', 'Returns cached response.');
await page.context().route('**/api*', route => route.continue());
await page.goto(server.PREFIX + '/frames/one-frame.html');
{

View File

@ -739,7 +739,7 @@ it('should respect cors overrides', async ({ page, server, browserName, isAndroi
}
});
it('should not auto-intercept non-preflight OPTIONS', async ({ page, server, isAndroid }) => {
it('should not auto-intercept non-preflight OPTIONS', async ({ page, server, isAndroid, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20469' });
it.fixme(isAndroid);
@ -793,7 +793,10 @@ it('should not auto-intercept non-preflight OPTIONS', async ({ page, server, isA
expect.soft(text1).toBe('Hello');
expect.soft(text2).toBe('World');
// Preflight for OPTIONS is auto-fulfilled, then OPTIONS, then GET without preflight.
expect.soft(requests).toEqual(['OPTIONS:/something', 'GET:/something']);
if (browserName === 'firefox')
expect.soft(requests).toEqual(['OPTIONS:/something', 'OPTIONS:/something', 'GET:/something']);
else
expect.soft(requests).toEqual(['OPTIONS:/something', 'GET:/something']);
}
});