Skip to content

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

test: update "page.goBack should work for file urls" to match status quo (#16810)

Dmitry Gozmanaac9df054203
diff --git a/tests/assets/consolelog.html b/tests/assets/consolelog.html
index 7fa1b211a4..9ef271812d 100644
--- a/tests/assets/consolelog.html
+++ b/tests/assets/consolelog.html
@@ -5,7 +5,7 @@
</head>
<body>
<script>
- console.log('yellow')
+ console.log('here:' + location.href)
</script>
</body>
</html>
diff --git a/tests/page/page-event-console.spec.ts b/tests/page/page-event-console.spec.ts
index 34adfc88a0..ae4299484f 100644
--- a/tests/page/page-event-console.spec.ts
+++ b/tests/page/page-event-console.spec.ts
@@ -138,7 +138,7 @@ it('should trigger correct Log', async ({ page, server, browserName, isWindows }
it('should have location for console API calls', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
const [message] = await Promise.all([
- page.waitForEvent('console', m => m.text() === 'yellow'),
+ page.waitForEvent('console', m => m.text().startsWith('here:')),
page.goto(server.PREFIX + '/consolelog.html'),
]);
expect(message.type()).toBe('log');
diff --git a/tests/page/page-history.spec.ts b/tests/page/page-history.spec.ts
index 6b4fbc7a0b..f825458afe 100644
--- a/tests/page/page-history.spec.ts
+++ b/tests/page/page-history.spec.ts
@@ -53,20 +53,29 @@ 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.fail(browserName === 'webkit' && platform === 'darwin');
+ 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');
- // WebKit embedder fails to go back/forward to the file url.
- const url1 = url.pathToFileURL(asset('empty.html')).href;
- const url2 = server.EMPTY_PAGE;
- await page.goto(url1);
+ const url1 = url.pathToFileURL(asset('consolelog.html')).href;
+ const url2 = server.PREFIX + '/consolelog.html';
+ await Promise.all([
+ page.waitForEvent('console', message => message.text() === 'here:' + url1),
+ page.goto(url1),
+ ]);
await page.setContent(`<a href='${url2}'>url2</a>`);
expect(page.url().toLowerCase()).toBe(url1.toLowerCase());
- await page.click('a');
+ await Promise.all([
+ page.waitForEvent('console', message => message.text() === 'here:' + url2),
+ page.click('a'),
+ ]);
expect(page.url()).toBe(url2);
- await page.goBack();
+ await Promise.all([
+ page.waitForEvent('console', message => message.text() === 'here:' + url1),
+ page.goBack(),
+ ]);
expect(page.url().toLowerCase()).toBe(url1.toLowerCase());
// Should be able to evaluate in the new context, and
// not reach for the old cross-process one.
@@ -74,7 +83,10 @@ it('page.goBack should work for file urls', async ({ page, server, asset, browse
// Should be able to screenshot.
await page.screenshot();
- await page.goForward();
+ await Promise.all([
+ page.waitForEvent('console', message => message.text() === 'here:' + url2),
+ page.goForward(),
+ ]);
expect(page.url()).toBe(url2);
expect(await page.evaluate(() => window.scrollX)).toBe(0);
await page.screenshot();