mozilla / r2d2b2g

Firefox OS Simulator is a test environment for Firefox OS. Use it to test your apps in a Firefox OS-like environment that looks and feels like a mobile phone.
https://addons.mozilla.org/en-US/firefox/addon/firefox-os-simulator/
Other
393 stars 117 forks source link

Start the simulator with a custom profile path #715

Open kumar303 opened 11 years ago

kumar303 commented 11 years ago

It would be great to have a hidden pref that developers can toggle to set a custom path for -profile when starting the simulator. This would allow one to check out the gaia source, set custom preferences, build a custom profile, and get all the benefits of the simulator (dashboard, etc). This is an essential feature for developing the Firefox Marketplace because we need custom prefs to allow Dev payments.

mykmelez commented 11 years ago

@kumar303 and I discussed this on IRC, and I wouldn't want to expose this feature to regular users of the addon, but it seems like a reasonable hidden feature to provide to expert users who have this particular need. You can currently point the B2G executable inside the Simulator at another profile via the -profile command line option, but that doesn't give you access to the Dashboard, so it isn't as helpful as a hidden pref would be.

cvan commented 11 years ago

:+1: this would help immensely with payments development!

ochameau commented 11 years ago

We need special flags when building gaia and also needs prothesis to be installed in this profile. I tend to think it will be easier to do that from simulator sources.

You can already use a custom profile by running the simulator from source:

$ git clone https://github.com/mozilla/r2d2b2g.git
$ cd r2d2b2g
$ cd gaia
// do whatever necessary modification to gaia sources
// by default the simulator uses v1-train branch, but you can checkout master
$ cd ..
// We have similar files to what exists in gaia/build folder, to set custom settings/prefs
$ vi build/override-settings.json
$ vi build/override-prefs.js
$ make profile run
// And in order to avoid always using a new empty profile
$ BIN_ARG="-p /tmp/profile" make profile run
kumar303 commented 11 years ago

@ochameau I can already start b2g from the addon source (e.g. ~/Library/Application Support/Firefox/Profiles/.../r2d2b2g@mozilla.org) with a custom profile but that doesn't let me hook into the dashboard and all the nice simulator features. This issue is just asking to make the -profile path configurable here: https://github.com/mozilla/r2d2b2g/blob/master/addon/lib/remote-simulator-client.js#L473

ochameau commented 11 years ago

I crafted that patch, but then you miss prosthesis addon and all dashboard features are lost.

ochameau commented 11 years ago

See PR #722.

mykmelez commented 11 years ago

I crafted that patch, but then you miss prosthesis addon and all dashboard features are lost.

Perhaps we can address this by installing prosthesis into B2G's distribution/extensions folder instead of the Gaia profile, per https://developer.mozilla.org/en-US/docs/Developer_Guide/Customizing_Firefox#Including_extensions_with_your_distribution_of_Firefox.

mykmelez commented 11 years ago

@kumar303 As @ochameau notes, simply adding the pref (which he's done in a pull request) isn't going to give you what you want, because your Gaia profile would be missing some necessary bits for communicating with the Dashboard; so you wouldn't be able to use the Dashboard to push apps to the Simulator, you wouldn't be able to connect developer tools, etc.

We might be able to fix that problem, per my previous comment, although there may be undesirable side-effects. But since you already know how to build Gaia, I'm wondering the same thing @ochameau wondered: might it be possible for you to build the Simulator with your custom version of Gaia, so you have a Simulator build that works exactly the way you want?

Building the Simulator is very easy (although the initial build takes some time to download/build Gaia and its dependencies):

git clone https://github.com/mozilla/r2d2b2g.git
cd r2d2b2g
git submodule update --init
# Modify build/override-settings.json, build/override-prefs.js, and gaia/ as needed.
make && make package

The result will be a package at addon/r2d2b2g.xpi that you can install into Firefox via Tools > Add-ons > Install Add-on From File… or simply File > Open File… (or drag-drop into a browser window). Then, to rebuild after making additional changes to build/override-settings.json, build/override-prefs.js, or gaia/, just do:

make profile && make package

(There are some tighter build/use loops that don't require packaging the addon into a XPI after each set of changes, but they use a different Firefox profile, whereas presumably you'll want to use your existing one. But I can go into those details if needed.)

Perhaps it's worth trying this to see if it addresses your use case? If not, I'm happy to dig deeper into what it would take to use a custom Gaia with full Simulator & Dashboard functionality! Unfortunately, it turns out that that will take more than the simple pref we originally discussed.

kumar303 commented 11 years ago

ohhh, I see now. I'll try building one and see how it goes. Thanks.

mykmelez commented 11 years ago

@kumar303 how did it go?

wraithan commented 11 years ago

Building the add-on is really not a solution in my opinion. For payments work I am already updating the codebases I actually work on (fireplace, zamboni, webpay, solitude) and updating gaia every day, this adds having to update r2d2b2g every day and build it as well.

It seems like there should be some middle ground here. I understand that you are injecting your own stuff into gaia, which is what we are doing as well. We add 5-10 lines to gaia/build/custom-prefs.js to point at our local development servers.

wraithan commented 11 years ago

https://webpay.readthedocs.org/en/latest/use_hosted_webpay.html#build-a-custom-b2g-profile are the preferences that we add to our custom gaia builds that we use for development of payments.

kumar303 commented 11 years ago

I had a lot of trouble getting payments to work with my custom built addon. I'm not entirely sure what the deal was but I suspect that it was either a gaia or gecko problem, not something with the simulator. Here are my notes from what I did:

B2G_URL=http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-b2g18_v1_0_1/en-US/b2g-18.0.en-US.mac64.dmg make
make profile && make package
PROFILE=~/tmp/r2d2b2g-profile BIN="/Applications/FirefoxAurora.app" make run

I couldn't get Persona sign-ins to work and was poking around with the debugger (found the port with lsof -i -P | grep -i "b2g"). That didn't help much.