[docker/playwright] policies.json file not applied
Hey everyone. I am automating end-to-end testing with playwright for python, using the official Docker image from the microsoft artifact repository (using `playwright/python:v1.49.1`).
As I have signed certificates for my local domains with my own certificate authority, I am trying to have Firefox automatically install the certificates via a policies file. However, Firefox seems to ignore the policies file no matter what.
To ensure that the file itself is used, I simplified it to a single boolean value, and ensured that it's copied correctly inside the container via the `cat` command. Here are the current contents:
{
"policies": { "DisableTelemetry": true
}
I know that the CA certificate is installed correctly, as it works out of the box using the WebKit browser and Curl command. I have gotten it to work in Chromium by installing it to nssdb using `certutil`.
I have converted the file from ASCII to the `utf-8` charset.
The file has the expected content, and I have copied it to both `/etc/firefox/policies/policies.json` and `/ms-playwright/firefox-1466/firefox/distribution/policies.json` (the path to the binary is `/ms-playwright/firefox-1466/firefox/firefox`).
Opening `about:policies` shows the text "The Enterprise Policies service is inactive.", which is sadly not very informative. It would be nice to have a list of locations it looks in, and any problems it encountered.
The container uses Firefox Nightly 132.
Are these locations incorrect? Is there any way to debug this? Does anyone have any other suggestions? If you need any more info (Dockerfile, etc.), please let me know.
Thanks in advance.
Edeziri
All Replies (10)
Rather you should post that to bugzilla for the devs to look at what is going on as since this is just a user help forum.
markwarner22 said
Rather you should post that to bugzilla for the devs to look at what is going on as since this is just a user help forum.
I'm not entirely sure that is a bug, or if it's just me doing something wrong, and whether it even belongs in the Firefox Bugzilla (I think it's mostly an issue with the Playwright docker container, if anything), but I was hoping someone already encountered and solved this issue :)
Then you might want to ask them this as well since that is their hardware and software and maybe something is missing to make it connect.
The hardware is mine, actually. I am running tests locally. Webkit and Chromium recognize my CA within the container. Firefox does not.
Firefox on my host machine does recognize it, but that's a different environment.
I'll also open an issue on the Playwright repo, I guess.
Then another set of programmers eyes might need to look and see what else they can see is happening since this is your programming code is doing on Firefox.
Forget about my code. Or code in general.
The issue is that Firefox in the container does not apply rules from `policies.json` files. If anyone has gotten FF to work with those in a Playwright container, I would appreciate knowing how.
If anyone knows how I can get a list of directories FF checks for those (from a running instance, since it ignores the files listed in the docs), I would like to know where to check.
If Firefox logs that information somewhere (it's not in stdout), then I would like to know that...
Basically, I am looking for anything that can help me debug this Firefox-specific issue, even if it's in a somewhat esoteric environment.
I'm not sure whether the build process itself introduces strange variables, but FF ignoring /etc/firefox/policies/policies.json makes me think something is strange.
Edeziri
markwarner22, if you do not understand then move on instead of continuing.
Pat B said
The container uses Firefox Nightly 132.
Which is a old random Nightly development channel build when the current Nightly channel builds are at Firefox 135.0.a1 https://www.mozilla.org/firefox/all/desktop-nightly/linux64/ and current Release is 134.0.2 https://www.mozilla.org/firefox/all/desktop-release/linux64/
James said
Which is a old random Nightly development channel build
Totally a fair point, but that is what Microsoft provides at the moment. The JS version of Playwright was updates yesterday, and I imagine the Python version will follow shortly.
At any rate, I am still curious why it would ignore the file in the /etc/firefox/ directory.
Edeziri
Note that your screenshot and posted text lacks a closing curly bracket, you open two and close one. Try this:
{ "policies": { "DisableTelemetry": true } }
You can always check the Web Console Browser Console and the Error tab in about:policies to see if there are errors reported.
Edeziri
Welp, so much for me "simplifying" things via my edits. Sorry about that, but the error I introduced by cutting one line too many was unrelated 😅
The problem still persists even after fixing that JSON file, unfortunately, as seen in the newest screenshot.
The console also seems to provide no relevant information in this case.