test: add a regression test for reload bug in firefox (#21282)

References https://github.com/microsoft/playwright/issues/20791
This commit is contained in:
Andrey Lushnikov 2023-02-28 16:05:12 -08:00 committed by GitHub
parent de3a5e2a91
commit b607c92651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(`
<!doctype html>
<script type="text/javascript">
console.log(window.parent.foo);
</script>
`);
});
server.setRoute('/main.html', (req, res) => {
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
res.end(`
<!doctype html>
<iframe id=myframe src="about:blank"></iframe>
<script type="text/javascript">
setTimeout(() => window.foo = 'foo', 0);
setTimeout(() => myframe.contentDocument.location.href = '${server.PREFIX}/iframe.html', 0);
</script>
`);
});
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']);
});