test: add more tests for reload (#21296)

Make sure `page.reload()` doesn't reload a related popup and
only reloads target page.
This commit is contained in:
Andrey Lushnikov 2023-03-01 10:52:55 -08:00 committed by GitHub
parent f8100bbb25
commit 4d3b056f27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -267,3 +267,30 @@ it('regression test for issue 20791', async ({ page, server }) => {
await page.reload();
await expect.poll(() => messages).toEqual(['foo', 'foo']);
});
it('should reload proper page', async ({ page, server }) => {
let mainRequest = 0, popupRequest = 0;
server.setRoute('/main.html', (req, res) => {
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
res.end(`<!doctype html><h1>main: ${++mainRequest}</h1>`);
});
server.setRoute('/popup.html', (req, res) => {
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
res.end(`<!doctype html><h1>popup: ${++popupRequest}</h1>`);
});
await page.goto(server.PREFIX + '/main.html');
const [popup] = await Promise.all([
page.waitForEvent('popup'),
page.evaluate(() => window.open('/popup.html')),
]);
await expect(page.locator('h1')).toHaveText('main: 1');
await expect(popup.locator('h1')).toHaveText('popup: 1');
await page.reload();
await expect(page.locator('h1')).toHaveText('main: 2');
await expect(popup.locator('h1')).toHaveText('popup: 1');
await popup.reload();
await expect(page.locator('h1')).toHaveText('main: 2');
await expect(popup.locator('h1')).toHaveText('popup: 2');
});