Vlad Filippov

Vlad Filippov

software engineer / web dev / open source hacker

How to quickly write a front-end Firefox patch

Here’s yet another guide that helps you land some code into mozilla-central.

Use this guide to fix something or add cool stuff to the Firefox web browser. This guide assumes you want to make “front-end” changes to Firefox – which means you are not making any changes to C++ components of the browser. The goal behind this guide is speed!

I’m going to use Mercurial (hg) for this, so clone mozilla-central:

hg clone https://hg.mozilla.org/mozilla-central

While it is cloning – go and create a BugZilla account if you don’t have one. Install the required prerequisites for mac OS or Windows or Linux.

After the repository has finished cloning, run the following to make sure all prerequisites are properly installed. Make sure to select the “artifact” build option to get fast builds. Also make sure to configure MozReview if you are presented with that option.

Run the following to setup your Mercurial to support Firefox development (In my case I usually answer “Yes” to all Mercurial setup steps):

./mach mercurial-setup

Run the following to setup all the dependencies that are required for Firefox to build:

./mach bootstrap

Now a bit of configuration. Enable “Artifact builds” – create a file called mozconfig in the root of the clone mozilla-central directory and add the following:

ac_add_options --enable-artifact-builds

Enable MozReview connectivity. Add your BugZilla email the to the following ~/.ssh/config file:

Host hg.mozilla.org
  User YOUR@BUGZILLA_EMAIL.com

Host reviewboard-hg.mozilla.org
  User YOUR@BUGZILLA_EMAIL.com

Time to write some code! You can now make the changes you want to mozilla-central code.

Use hg add to add the changed files and commit using hg commit. Your commit message should have the following format:

Bugzilla #BUG_NUMBER - Description

Once you committed use hg push review. Make sure the code is pushed, press Y to publish the commit for review.

You can now ask for review. Navigate to https://reviewboard.mozilla.org/r/[your_patch_id] and add reviewers using the pencil button under “Reviewers”.

Once your code is reviewed you probably want to make some changes to it. Make those changes and use the hg commit --amend command. Push the changes with the hg push review command again. If your patch gets an r+ then it will get merged!

Hopefully this guide help you quickly get started. Tweet at me if you have any questions about this or if you found issues with this guide!