playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] Firefox tests crash with "Unexpected number of tabs in the new window"

Open gcatto opened this issue 4 years ago • 31 comments

Context:

  • Playwright Version: 1.13.1
  • Operating System: Windows
  • Node.js version: v12.22.4
  • Browser: Firefox
  • Extra: N/A

Code Snippet

Help us help you! Put down a short code snippet that illustrates your bug and that we can run and debug locally. For example:

C:\dev>npx playwright ff google.com
[open: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:321:13

] {
  name: 'Error'
}

Describe the bug

Trying to run tests, even just using the npx playwright ff google.com command as per above, crashes in Firefox immediately. When I run not in headless, I can see the extra Firefox privacy tab:

image

gcatto avatar Aug 11 '21 16:08 gcatto

@gcatto interesting! Do you have any enterprise policies installed on your machine? I just ran the same thing and it works perfectly fine for me.

aslushnikov avatar Aug 12 '21 09:08 aslushnikov

@aslushnikov ah yes, this is on an enterprise machine with enterprise policies and enterprise firefox. Just learning my way around Playwright so far, not yet clear to me how Playwright interacts with installed browsers and such.

gcatto avatar Aug 12 '21 10:08 gcatto

@aslushnikov any further thoughts or guidance on this front? Not really sure where/how to start tackling it. Thanks!

gcatto avatar Aug 20 '21 14:08 gcatto

~~I'm able to reproduce:~~

I had a broken installation.

mxschmitt avatar Aug 23 '21 21:08 mxschmitt

@gcatto could you try if its still reproducible with npx playwright@next ff google.com?

mxschmitt avatar Aug 27 '21 15:08 mxschmitt

@mxschmitt Just tried it out, and unfortunately got the same error:

C:\dev>npx playwright@next ff google.com
[open: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:322:13

] {
  name: 'Error'
}

gcatto avatar Aug 27 '21 18:08 gcatto

Hi all,

do you know any workaround for this please? Reproducible on my enterprise laptop, not on my private one: Playwright version: 1.16.0 (Java) `com.microsoft.playwright.PlaywrightException: Error { message='Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:323:13

... }`

Best regards

rado-o avatar Oct 23 '21 09:10 rado-o

Hi, I have the same issue on Windows.

Playwright Version: 1.16.3

browser.newPage: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:323:13

Is there any workaround?

cristinac42 avatar Nov 17 '21 17:11 cristinac42

Hi, I have the same issue on Windows.

Playwright Version: 1.16.3

browser.newPage: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:323:13

Is there any workaround?

I solved by using 1.17.0-rc1 playwright version.

cristinac42 avatar Nov 24 '21 18:11 cristinac42

I see the same error with playwright 1.19.2.

$ npx playwright ff google.com
: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:324:13

    at captureRawStack (C:\myproject\node_modules\@playwright\test\node_modules\playwright-core\lib\utils\stackTrace.js:64:17) {
  name: 'Error'
}

sbley avatar Mar 01 '22 07:03 sbley

Getting the same error msg for Nodejs as well as for Java binding.

Nodejs: [firefox] › example.spec.ts:247:3 › Counter › should display the current number of todo items

browserContext.newPage: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:324:13

Java Exception in thread "main" com.microsoft.playwright.PlaywrightException: Error { message='Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:324:13

name='Error stack='Error: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:324:13

at C:\Users\RSALUN~1\AppData\Local\Temp\playwright-java-13735235671465553076\package\lib\server\firefox\ffConnection.js:92:16
at new Promise (<anonymous>)
at FFConnection.send (C:\Users\RSALUN~1\AppData\Local\Temp\playwright-java-13735235671465553076\package\lib\server\firefox\ffConnection.js:88:12)
at FFBrowserContext.newPageDelegate (C:\Users\RSALUN~1\AppData\Local\Temp\playwright-java-13735235671465553076\package\lib\server\firefox\ffBrowser.js:306:41)
at FFBrowserContext.newPage (C:\Users\RSALUN~1\AppData\Local\Temp\playwright-java-13735235671465553076\package\lib\server\browserContext.js:335:37)
at BrowserContextDispatcher.newPage (C:\Users\RSALUN~1\AppData\Local\Temp\playwright-java-13735235671465553076\package\lib\dispatchers\browserContextDispatcher.js:150:67)
at DispatcherConnection.dispatch (C:\Users\RSALUN~1\AppData\Local\Temp\playwright-java-13735235671465553076\package\lib\dispatchers\dispatcher.js:352:46)

} at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:54) at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:103) at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:105) at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:94) at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:90) at com.microsoft.playwright.impl.BrowserContextImpl.newPageImpl(BrowserContextImpl.java:323) at com.microsoft.playwright.impl.BrowserContextImpl.lambda$newPage$12(BrowserContextImpl.java:316) at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47) at com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:79) at com.microsoft.playwright.impl.BrowserContextImpl.newPage(BrowserContextImpl.java:316) at com.microsoft.playwright.impl.BrowserContextImpl.newPage(BrowserContextImpl.java:44) at main.WebKitScreenshot.main(WebKitScreenshot.java:26) Caused by: com.microsoft.playwright.impl.DriverException: Error { message='Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:324:13

name='Error

salunkhe-ravi avatar Mar 26 '22 08:03 salunkhe-ravi

Hey folks,

Are you all experiencing this on Windows? Do you have a repro that we can debug?

It does feel like there are some custom preferences (policy) in Firefox that override ours. Could it be the case?

aslushnikov avatar Mar 29 '22 19:03 aslushnikov

@aslushnikov - Yes on windows. Running any basic(Getting Started) example leads me to this error. However, if I downgrade the version to 1.17.0 - it doesn't throw any such error.

salunkhe-ravi avatar Mar 30 '22 10:03 salunkhe-ravi

I think I've had this problem at every version since I started using Playwright with 1.13.1, although I don't think I've used every major and minor version.

This happens for me on Windows on a corporate machine with Firefox ESR. Unsure about a repro to debug besides that, because I don't have insight/access to all the corporate policies and the like.

gcatto avatar Mar 30 '22 12:03 gcatto

I'd also like the chime in and say I'm running into the same issues using Firefox and Playwright version 1.20.1. All other browsers work

joeflan avatar Apr 18 '22 19:04 joeflan

I am also able to reproduce this issue with playwright version 1.22.1 With previous versions, this issue was not reproducible, recently I updated to playwright version 1.22 and started facing this issue.

browserContext.newPage: Protocol error (Browser.newPage): Unexpected number of tabs in the new window: 2 newPage@chrome://juggler/content/TargetRegistry.js:324:13


        at Object.page [as fn] (C:\{ProjectLocation}\node_modules\@playwright\test\lib\index.js:647:29)
        at C:\{ProjectLocation}\node_modules\@playwright\test\lib\fixtures.js:98:81

image

AmanDaharwal avatar Jun 28 '22 08:06 AmanDaharwal

Could you please try adding the browser.privacySegmentation.preferences.show preference?

const browser = await firefox.launch({
  firefoxUserPrefs: {
    'browser.privacySegmentation.preferences.show': false,
  }
});

aslushnikov avatar Aug 16 '22 11:08 aslushnikov

@aslushnikov With the setting you suggested I am getting the same error as before.

playwright:1.24.0

[Update] Also tested with playwright:1.30.0 and playwright:1.31.1

sbley avatar Aug 16 '22 11:08 sbley

@aslushnikov Getting the same issues again with above settings with playwright 1.24.2

Looks like an feature of Firefox which playwright is unable to handle - https://support.mozilla.org/en-US/questions/1257360

AmanDaharwal avatar Aug 18 '22 09:08 AmanDaharwal

I was having the same problem but I got it working again by deleting the firefox folder in the installation folder of the browsers or here C:/users/{user}/AppData/Local/ms-playwright and then installing again the browser.

"npx playwright install"

gineanne avatar Nov 28 '22 07:11 gineanne

Using 1.30.0 on Ubuntu 22.04.1, I still get this error with

Playwright.create().firefox().launch(new BrowserType.LaunchOptions().setHeadless(false).setFirefoxUserPrefs(Map.of("browser.privacySegmentation.preferences.show", false))).newContext().newPage();

even after

rm -rf ~/.cache/ms-playwright/firefox-1372

First a popup is shown

Failed to read the configuration file. Please contact your system administrator.

jglick avatar Feb 11 '23 16:02 jglick

Hello ! I had the same issue today with Playwright 1.30.0, it seems fixed in 1.31.0

adasilva-gran avatar Feb 28 '23 13:02 adasilva-gran

Hmm, I see 1.31.1 on https://mcr.microsoft.com/en-us/product/playwright/tags (curiously skopeo list-tags docker://mcr.microsoft.com/playwright/java does not show anything newer than 1.30.0), but for Java https://repo1.maven.org/maven2/com/microsoft/playwright/playwright/ seems stuck on 1.30.0.

jglick avatar Feb 28 '23 14:02 jglick

A new version of Java gets released soon!

mxschmitt avatar Feb 28 '23 15:02 mxschmitt

@adasilva-gran I still get the same error with playwright 1.31.1.

sbley avatar Feb 28 '23 18:02 sbley

Any update on this this is an issue of the privacy tab auto opening is there a workaround?

yb-cs avatar Jan 17 '24 11:01 yb-cs

One year later, I still get this error. I am currently on playwright 1.41.2 which comes with Firefox 121 (v1438).

sbley avatar Feb 06 '24 08:02 sbley

What i noticed is playwright does not create a Firefox profile in the temp folder (it does with chromium, though).

Here is part of the log using DEBUG=pw:browser:

  pw:browser <launching> C:\Users\bob\AppData\Local\ms-playwright\firefox-1438\firefox\firefox.exe -no-remote -headless -profile C:\Users\bob\AppData\Local\Temp\playwright_firefoxdev_profile-U9Nr3R -juggler-pipe -silent +0ms
  pw:browser <launched> pid=8644 +148ms
  pw:browser [pid=8644][err] *** You are running in headless mode. +287ms
  pw:browser [pid=8644][out] console.error: ({}) +673ms
  pw:browser [pid=8644][out]  +6ms
  pw:browser [pid=8644][out] Juggler listening to the pipe +0ms
  pw:browser [pid=8644][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt (t=13.9334) [GFX1-]: RenderCompositor
SWGL failed mapping default framebuffer, no dt +472ms
  pw:browser [pid=8644][err] JavaScript error: resource://gre/modules/XULStore.sys.mjs, line 60: Error: Can't find profile directory. +367ms

Now, when I run this firefox.exe command manually in a terminal, I get the playwright_firefoxdev_profile-U9Nr3R in the temp folder, but only if I remove the -juggler-pipe parameter.

sbley avatar Feb 06 '24 09:02 sbley

--pref='datareporting.policy.firstRunURL=""' can fix it source: Firefox loads privacy info page @gcatto

CLannadZSY avatar Mar 20 '24 06:03 CLannadZSY

--pref='datareporting.policy.firstRunURL=""' can fix it source: Firefox loads privacy info page @gcatto

Good tip, thank you!

gcatto avatar Mar 20 '24 11:03 gcatto