Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

implement foxr.launch() #5

Closed
deepsweet opened this issue Aug 9, 2018 · 28 comments
Closed

implement foxr.launch() #5

deepsweet opened this issue Aug 9, 2018 · 28 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@deepsweet
Copy link
Owner

deepsweet commented Aug 9, 2018

https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/docs/api.md#puppeteerlaunchoptions

  • download Firefox
    • which version and how to control that?
    • multiplatform
  • unpack it
    • to where?
  • run it as child process with necessary args and profile
  • kill that process on browser.close()
@deepsweet deepsweet added the enhancement New feature or request label Aug 9, 2018
@deepsweet deepsweet self-assigned this Aug 9, 2018
@deepsweet deepsweet changed the title implement foxr.launch implement foxr.launch() Aug 14, 2018
@deepsweet deepsweet removed their assignment Aug 16, 2018
@deepsweet deepsweet added the help wanted Extra attention is needed label Aug 16, 2018
@saidsay-so
Copy link
Contributor

saidsay-so commented Sep 8, 2018

I have investigated and there is some problems:

I don't know if macOS dmg's will do the trick but Linux versions seems to work.

@deepsweet
Copy link
Owner Author

Hi.

macOS .dmg is just a renamed .zip archive, should just work.

Regarding Windows – I found this:

Not sure how much we can trust these sources though.

@deepsweet
Copy link
Owner Author

@saidsay-so
Copy link
Contributor

saidsay-so commented Sep 8, 2018

Sorry, hi !
I'm not sure about firefox-usb but I know that Firefox Portable is open-source.
And get-firefox seems to be more a CLI app than an usable API.
Edit: nevermind, get-firefox is good.

@saidsay-so
Copy link
Contributor

saidsay-so commented Sep 9, 2018

Ok so I tried to build the launch() function with get-firefox but it was more easy to proceed using taskcluster-container.
I finally succeed to download Firefox but when I launched it, I discovered that it needs to create a new profile to make it separated from other firefox processes and preferences.

@deepsweet
Copy link
Owner Author

Yeah, I've already done this in my dockerized headless Firefox project, see args and profile. We could place the profile in the same folder to where we downloaded Firefox.

@saidsay-so
Copy link
Contributor

I didn't looked at it before, it would have helped me a lot !
The problem that I was facing is the -profile argument for which I gave a file instead of a folder.
But now I will test it.

@saidsay-so
Copy link
Contributor

So for now my launch() create a directory using tmpdir() and mkdtemp('foxr-') and make all the operations inside it.

@deepsweet
Copy link
Owner Author

deepsweet commented Sep 9, 2018

I'd check where Puppeteer stores Chromium, it feels like it's in their module folder inside of node_modules/.

Also, I'd like to initially implement this as a separate package to not make the same mistake as Puppeteer – see puppeteer vs puppeteer-core. Something like you have to install foxr and download-firefox-blah-blah to avoid PUPPETEER_SKIP_CHROMIUM_DOWNLOAD env var hackaround and then launch() will do the rest. Also we can transform this repo into a monorepo with @foxr namespace, I've it registered already. What do you think?

Thanks for your investigation!

@saidsay-so
Copy link
Contributor

saidsay-so commented Sep 10, 2018

So launch() will have to test the presence of download-firefox and use an exported function ?
And yes, using a namespace would be a great idea to manage with ease the repos !

@deepsweet
Copy link
Owner Author

will have to test the presence of download-firefox and use an exported function

That's the weak part of my idea :) My personal usage of Foxr/Puppeteer is limited to an external dockerized solution, so that PUPPETEER_SKIP_CHROMIUM_DOWNLOAD felt like a hack until they introduced puppeteer-core thing. There is no need to download entire browser by default, I believe that it should be an opt-in.

How to wire it together is a good question.

launch() has an executablePath option, so maybe "downloader" can export some property with the file path of downloaded browser.

@foolip
Copy link

foolip commented Sep 11, 2018

@jgraham probably knows how to download Firefox automatically, this is done in web-platform-tests, although in Python, here:
https://github.com/web-platform-tests/wpt/blob/59bed3508ceae6bd16e31971c3d0448d13a5113b/tools/wpt/browser.py#L132

@saidsay-so
Copy link
Contributor

Thanks for the help! But I already built a module that can do this. The problem is how to "modularize" the function.

@deepsweet
Copy link
Owner Author

If you choose a path to download Firefox in deterministic way, i.e. it doesn't have random parts and it gives the same result every time, you can export it and pass to Foxr:

foxr.launch({
  executablePath: firefoxDownloader.getPath()
})

@saidsay-so
Copy link
Contributor

The path could change with the OS (maybe not if it's relative) ?

@deepsweet
Copy link
Owner Author

It's fine as long as "firefox-downloader" module will use the same path as it returns with getPath().

@saidsay-so
Copy link
Contributor

saidsay-so commented Sep 13, 2018

I pushed my changes on the launch branch of my fork !

@deepsweet
Copy link
Owner Author

Looks good! I'm a bit off this project for the last few days, but will come back really soon.

@deepsweet
Copy link
Owner Author

Alright.

I'm going to implement launch() as an abstract downloads-free method, and then we'll think about a monorepo under @foxr NPM scope.

@saidsay-so
Copy link
Contributor

Ok

@saidsay-so
Copy link
Contributor

saidsay-so commented Sep 21, 2018

I created a (basic) module to download Firefox. https://github.com/MusiKid/firefox-downloader

deepsweet added a commit that referenced this issue Sep 23, 2018
@saidsay-so
Copy link
Contributor

The module is more complete now. macOS support needs to be tested however.

@deepsweet
Copy link
Owner Author

Nice. Shouldn't download() be await'ed in readme?

@saidsay-so
Copy link
Contributor

Effectively !

@saidsay-so
Copy link
Contributor

So where should Firefox be extracted ?

@deepsweet
Copy link
Owner Author

I'm not quite sure. What's your current solution?

@saidsay-so
Copy link
Contributor

I don't know

@saidsay-so
Copy link
Contributor

Maybe just let the user define it ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants