Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] How to pass a policies.json to firefox launch #18115

Open
enrialonso opened this issue Oct 16, 2022 · 7 comments
Open

[Feature] How to pass a policies.json to firefox launch #18115

enrialonso opened this issue Oct 16, 2022 · 7 comments

Comments

@enrialonso
Copy link

Hi! I need launch a firefox browser but with a somes policies.json. How can do this with playwright?

On Firefox you can create a distribution folder on the instalation path for Firefox and set the policies for the browser, here speak about this

I am test on Ubuntu 22 and my distribution firefox browser read the policies and apply then, but playwright for some reason can't read this and not apply the policies en the firefox browser launch.

Example policie:

{
 "policies": {
   "BlockAboutConfig": true
 }
}

What is the correct way to load the policies for firefox browser?

PD: I try put the policy of the binary download folder for the firefox browser for playwright and not work, any idea how to do this?

/home/user/.cache/ms-playwright/firefox-1357/firefox

And apologies for my basic english

@dgozman
Copy link
Contributor

dgozman commented Oct 17, 2022

@enrialonso You can specify user preferences instead.

For example, to block about:config, place the following in the playwright.config.ts:

export default {
  use: {
    launchOptions: {
      firefoxUserPrefs: {
        'general.aboutConfig.enable': false,
      },
    },
  },
};

If you launch browser manually:

import { firefox } from '@playwright/test';

await firefox.launch({
  headless: false,
  firefoxUserPrefs: {
    'general.aboutConfig.enable': false,
  },
});

Let me know if this helps.

@enrialonso
Copy link
Author

@dgozman thx for the quick reply but I have special interest on policies, this example for the about configuration.

For example for firefox we can't put a security device for authentication, the method for load programaticaly the security device is put then on the policies. In this link you can look the config of the policies, how to set this on playwright is my question.

this link speak about that, I test on my firefox broser and works fine, but can't do this on playwright.

https://support.mozilla.org/en-US/kb/customizing-firefox-using-policiesjson

Any idea?

@dgozman
Copy link
Contributor

dgozman commented Oct 17, 2022

@enrialonso It is not possible to provide policies.json to Playwright today. I'll leave this issue open as a feature request.

@dgozman dgozman changed the title [Question] How to pass a policies.json to firefox launch [Feature] How to pass a policies.json to firefox launch Oct 17, 2022
@slebs
Copy link

slebs commented Jun 20, 2023

This would be crucial to be able to load root ca certificates on linux. Currently I haven't found any way to get certificates installed in firefox without using a persistent profile. Which can not be configured on "project" level either ( kind of related to #11833)

Interestingly firefox also does not pickup a policies.json if placed in the distribution folder of the playwright provided firefox. (~/.cache/ms-playwright/firefox-1408/firefox/distribution) Unsure how playwright manages to prevent that behaviour from firefox as documented here: https://github.com/mozilla/policy-templates/blob/master/README.md
If that is intentional I would be curious why it is done.

@lawrence-forooghian
Copy link

Yep, I’m having the same issue as described in #18115 (comment); profiles.json is Firefox’s recommended cross-platform solution for installing root CA certificates, so to be unable to use it in Playwright’s version of Firefox is a bit limiting.

@Coread
Copy link

Coread commented Apr 22, 2024

This would be crucial to be able to load root ca certificates on linux. Currently I haven't found any way to get certificates installed in firefox without using a persistent profile. Which can not be configured on "project" level either ( kind of related to #11833)

Interestingly firefox also does not pickup a policies.json if placed in the distribution folder of the playwright provided firefox. (~/.cache/ms-playwright/firefox-1408/firefox/distribution) Unsure how playwright manages to prevent that behaviour from firefox as documented here: https://github.com/mozilla/policy-templates/blob/master/README.md If that is intentional I would be curious why it is done.

Playwright is modifying the firefox source code to hardcode the disablement of enterprise policies. (see https://github.com/microsoft/playwright/blob/dd1a9f5e9637c37b25ca05e83c860b32abb7930d/browser_patches/firefox/patches/bootstrap.diff) I worked around this on linux by unzipping the omni.ja (zip file), modifying EnterprisePoliciesParent.sys.mjs to undo that part of the patch and then zipping it up again.

After making that change, putting the policies.json in <ff install dir>/distribution works.

It would be really helpful if playwright could support enterprise policies in firefox using a config option. Perhaps it could switch it on in EnterprisePoliciesParent.sys.mjs using an environment variable, or perhaps even a custom firefox config option?

@cscheffauer
Copy link

cscheffauer commented Apr 22, 2024

+1 for adding a way to configure the profiles / policies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants