Skip to content

Commit

Permalink
fix(firefox): fix reload with hash URLs
Browse files Browse the repository at this point in the history
While this fixes the regression, this breaks the microsoft#20791.
We'll fix it separately.

Fixes microsoft#21145
  • Loading branch information
aslushnikov committed Mar 2, 2023
1 parent 6a7347f commit 286fde2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/firefox/ffPage.ts
Expand Up @@ -393,7 +393,7 @@ export class FFPage implements PageDelegate {
}

async reload(): Promise<void> {
await this._session.send('Page.reload');
await this._page._frameManager.mainFrame().softReload();
}

async goBack(): Promise<boolean> {
Expand Down
6 changes: 6 additions & 0 deletions packages/playwright-core/src/server/frames.ts
Expand Up @@ -1512,6 +1512,12 @@ export class Frame extends SdkObject {
return context.evaluate(() => document.title);
}

// This is a workaround for https://github.com/microsoft/playwright/issues/21145
async softReload(): Promise<void> {
const context = await this._utilityContext();
await context.evaluate(() => window.location.reload());
}

async rafrafTimeout(timeout: number): Promise<void> {
if (timeout === 0)
return;
Expand Down
4 changes: 2 additions & 2 deletions tests/page/page-history.spec.ts
Expand Up @@ -187,7 +187,6 @@ it('page.reload should work with cross-origin redirect', async ({ page, server,

it('page.reload should work on a page with a hash', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21145' });
it.fixme(browserName === 'firefox');
await page.goto(server.EMPTY_PAGE + '#hash');
await page.reload();
await expect(page).toHaveURL(server.EMPTY_PAGE + '#hash');
Expand Down Expand Up @@ -237,8 +236,9 @@ it('page.goForward during renderer-initiated navigation', async ({ page, server
await page.waitForSelector('text=hello');
});

it('regression test for issue 20791', async ({ page, server }) => {
it('regression test for issue 20791', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/20791' });
it.fixme(browserName === 'firefox');
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.
Expand Down

0 comments on commit 286fde2

Please sign in to comment.