Vlad Filippov

Vlad Filippov

full-stack software developer / 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.

UPDATED: September 2017.

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, make sure you have it installed on your machine (On a Mac use brew install hg).

Clone mozilla-central with hg:

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, make sure it writes the config to `.hgrc` in the end:

./mach mercurial-setup

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

./mach bootstrap

Press 1 for Firefox for Desktop Artifact Mode. After the script it is done it will ask you to check if HG (Mercurial) is configured correctly. Say “Yes” to the prompts.

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:

Bug BUG_NUMBER - Description

If you know the reviewer for your patch then use the following format:

Bug BUG_NUMBER - Description r=username

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 helps you quickly get started. Tweet at me if you have any questions about this or if you found any issues with it!

© Vlad Filippov