Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: disable memory cache when intercepting in webkit (#28458)
Yury Semikhatskyb1661892477c
diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.tsindex 1ae8d23082..a8a007162b 100644--- a/packages/playwright-core/src/server/webkit/wkPage.ts+++ b/packages/playwright-core/src/server/webkit/wkPage.ts@@ -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 }),]);}diff --git a/tests/page/interception.spec.ts b/tests/page/interception.spec.tsindex 140346de69..c381e9f6e3 100644--- a/tests/page/interception.spec.ts+++ b/tests/page/interception.spec.ts@@ -172,3 +172,21 @@ it('should not break remote worker importScripts', async ({ page, server, browseawait 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);+});