playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Firefox browserContext does not isolate link history

Open Bickio opened this issue 3 years ago • 2 comments

Context:

  • Playwright Version: 1.27.1
  • Operating System: Linux
  • Node.js version: 16.15.0
  • Browser: Firefox

Code Snippet

import { test, expect } from "@playwright/test";

test("Page", async ({ page }) => {
  await page.goto("/page");
});

test("Homepage with link to /page", async ({ page }) => {
  await page.goto("/");
  await expect(page).toHaveScreenshot();
});

Describe the bug

The index page / has an anchor pointing to /page.

When running the tests in separate workers, the anchor shows as not visited (blue). This is correct behaviour.

However, when running the tests in the same worker, the anchor tag displays as visited (purple) in firefox only. This leads to the screenshot comparison failing the first time.

Evidently, firefox's browserContexts are not truly isolated.

Bickio avatar Oct 22 '22 04:10 Bickio

I can repro with:

test("Page", async ({ page }) => {
  await page.goto("https://example.com/page");
});

test("Homepage with link to /page", async ({ page }) => {
  await page.goto("https://example.com/");
  await page.setContent(`<a href="/page">Page</a>`);
  await expect(page).toHaveScreenshot();
});

mxschmitt avatar Oct 24 '22 17:10 mxschmitt

Investigation notes: Firefox keeps visited links history in the "places db", see ConcurrentStatementsHolder in History.cpp that reads it from the db.

dgozman avatar Dec 14 '22 22:12 dgozman

Workaround - set firefox user preference in project settings { name: 'firefox', use: { ...devices['Desktop Firefox'], launchOptions: { firefoxUserPrefs: {'layout.css.visited_links_enabled':false} } }, },

ekarin-dia avatar Sep 11 '23 04:09 ekarin-dia

Why was this issue closed?

Thank you for your contribution to our project. This issue has been closed due to its limited upvotes and recent activity, and insufficient feedback for us to effectively act upon. Our priority is to focus on bugs that reflect higher user engagement and have actionable feedback, to ensure our bug database stays manageable.

Should you feel this closure was in error, please create a new issue and reference this one. We're open to revisiting it given increased support or additional clarity. Your understanding and cooperation are greatly appreciated.

pavelfeldman avatar Apr 22 '24 17:04 pavelfeldman