fix: disable memory cache when intercepting in webkit (#28458)
This commit is contained in:
parent
f44ef81af7
commit
b166189247
|
|
@ -185,6 +185,7 @@ export class WKPage implements PageDelegate {
|
|||
];
|
||||
if (this._page.needsRequestInterception()) {
|
||||
promises.push(session.send('Network.setInterceptionEnabled', { enabled: true }));
|
||||
promises.push(session.send('Network.setResourceCachingDisabled', { disabled: true }));
|
||||
promises.push(session.send('Network.addInterception', { url: '.*', stage: 'request', isRegex: true }));
|
||||
}
|
||||
if (this._page._browserContext.isSettingStorageState()) {
|
||||
|
|
@ -723,6 +724,7 @@ export class WKPage implements PageDelegate {
|
|||
const enabled = this._page.needsRequestInterception();
|
||||
await Promise.all([
|
||||
this._updateState('Network.setInterceptionEnabled', { enabled }),
|
||||
this._updateState('Network.setResourceCachingDisabled', { disabled: enabled }),
|
||||
this._updateState('Network.addInterception', { url: '.*', stage: 'request', isRegex: true }),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,3 +172,21 @@ it('should not break remote worker importScripts', async ({ page, server, browse
|
|||
await page.goto(server.PREFIX + '/worker/worker-http-import.html');
|
||||
await page.waitForSelector("#status:has-text('finished')");
|
||||
});
|
||||
|
||||
it('should disable memory cache when intercepting', async ({ page, server }) => {
|
||||
let interceted = 0;
|
||||
await page.route('**/page.html', route => {
|
||||
++interceted;
|
||||
void route.fulfill({
|
||||
body: 'success'
|
||||
});
|
||||
});
|
||||
await page.goto(server.PREFIX + '/page.html');
|
||||
expect(await page.locator('body').textContent()).toContain('success');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await expect(page).toHaveURL(server.EMPTY_PAGE);
|
||||
expect(interceted).toBe(1);
|
||||
await page.goBack();
|
||||
await expect(page).toHaveURL(server.PREFIX + '/page.html');
|
||||
expect(interceted).toBe(2);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue