diff --git a/tests/page/page-history.spec.ts b/tests/page/page-history.spec.ts
index 2403b38949..2d04c54ac6 100644
--- a/tests/page/page-history.spec.ts
+++ b/tests/page/page-history.spec.ts
@@ -236,3 +236,34 @@ it('page.goForward during renderer-initiated navigation', async ({ page, server
// to the original one-style.html.
await page.waitForSelector('text=hello');
});
+
+it('regression test for issue 20791', async ({ page, server }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20791' });
+ server.setRoute('/iframe.html', (req, res) => {
+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
+ // iframe access parent frame to log a value from it.
+ res.end(`
+
+
+ `);
+ });
+ server.setRoute('/main.html', (req, res) => {
+ res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
+ res.end(`
+
+
+
+ `);
+ });
+ const messages = [];
+ page.on('console', msg => messages.push(msg.text()));
+ await page.goto(server.PREFIX + '/main.html');
+ await expect.poll(() => messages).toEqual(['foo']);
+ await page.reload();
+ await expect.poll(() => messages).toEqual(['foo', 'foo']);
+});