mozilla / web-ext

A command line tool to help build, run, and test web extensions
Mozilla Public License 2.0
2.64k stars 335 forks source link

Run arbitrary chromium-based flatpak browsers (Ungoogled Chromium) #2886

Open Extarys opened 10 months ago

Extarys commented 10 months ago

Is this a feature request or a bug?

Ability to run a third party flatpak such as UngoogledChromium

What is the current behavior?

Command:

"serve:chrome": "wait-on ./dist/manifest.json && web-ext run -t chromium --chromium-binary \"flatpak run com.github.Eloston.UngoogledChromium\" --start-url \"https://perdu.com\" --source-dir ./dist/",

I also tried playing with flatpak:com.github.Eloston.UngoogledChromium and gave it permission to /tmp directory through FlatSeal just in case.

Result:

node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: spawn flatpak -- run com.github.Eloston.UngoogledChromium ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn flatpak -- run com.github.Eloston.UngoogledChromium',
  path: 'flatpak -- run com.github.Eloston.UngoogledChromium',
  spawnargs: [
    '--remote-debugging-port=43417',
    '--user-data-dir=/tmp/tmp-web-ext--37931-J2PLlwa2qYiq',
    '--disable-features=Translate',
    '--disable-component-extensions-with-background-pages',
    '--disable-background-networking',
    '--disable-component-update',
    '--disable-client-side-phishing-detection',
    '--disable-sync',
    '--metrics-recording-only',
    '--disable-default-apps',
    '--no-default-browser-check',
    '--no-first-run',
    '--disable-backgrounding-occluded-windows',
    '--disable-renderer-backgrounding',
    '--disable-background-timer-throttling',
    '--disable-ipc-flooding-protection',
    '--password-store=basic',
    '--use-mock-keychain',
    '--force-fieldtrials=*BackgroundTracing/default/',
    '--load-extension=/tmp/tmp-web-ext--37931-oxGlgzAakWJg/reload-manager-extension-1695305384803,/mnt/data/webext/x/dist',
    'https://google.com'
  ]
}

Node.js v18.17.1

What is the expected or desired behavior?

Ability to run arbitrary flatpak browsers (chromium based) for testing purposes. (Test V3 extension compatibility)

Version information (for bug reports)

node --version && npm --version && web-ext --version
v18.17.1
9.6.7
7.7.0

Similar to https://github.com/mozilla/web-ext/issues/2465

rpl commented 10 months ago

In #2477 we introduced support for handling a similar issue in flatpak packaged Firefox, by running it through flatpak run along with the --filesystem option passed, in theory something similar could be done for flatpak packaged Chromium too.

For chrome we don't launch it directly but we leave that to the chrome-launcher dependency and so I'd prefer to don't hack around that for this corner case, an alternative approach could be to write a small shell script which will be running the flatpak package Chromium through flatpak run and passint similar options to the ones we are passing to flapak packaged Firefox (which you can retrive by looking to the PR linked above) and pass the path to that shell script to the existing command line option to specify the path to the chromium executable.

@Extarys Would you mind to try out this workaround and report back to us if that worked?