Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: add a test for bfcache and history navigations (#17796)

Dmitry Gozman99266e48ecb7
diff --git a/tests/page/page-history.spec.ts b/tests/page/page-history.spec.ts
index f825458afe..58a8bcb48f 100644
--- a/tests/page/page-history.spec.ts
+++ b/tests/page/page-history.spec.ts
@@ -53,7 +53,6 @@ it('page.goBack should work with HistoryAPI', async ({ page, server }) => {
});
it('page.goBack should work for file urls', async ({ page, server, asset, browserName, platform, isAndroid }) => {
- it.fixme(browserName === 'firefox', 'Firefox pretends, but does not complete goBack to the file url');
it.fail(browserName === 'webkit' && platform === 'darwin', 'WebKit embedder fails to go back/forward to the file url.');
it.skip(isAndroid, 'No files on Android');
@@ -92,6 +91,18 @@ it('page.goBack should work for file urls', async ({ page, server, asset, browse
await page.screenshot();
});
+it('goBack/goForward should work with bfcache-able pages', async ({ page, server }) => {
+ await page.goto(server.PREFIX + '/cached/one-style.html');
+ await page.setContent(`<a href=${JSON.stringify(server.PREFIX + '/cached/one-style.html?foo')}>click me</a>`);
+ await page.click('a');
+
+ let response = await page.goBack();
+ expect(response.url()).toBe(server.PREFIX + '/cached/one-style.html');
+
+ response = await page.goForward();
+ expect(response.url()).toBe(server.PREFIX + '/cached/one-style.html?foo');
+});
+
it('page.reload should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
await page.evaluate(() => window['_foo'] = 10);