# Beginner's Guide to Contributing to Mozilla Firefox

Mozilla Firefox contribution guide will help you if you want to make some open source contributions to the Mozilla Firefox browser. [Mozilla Firefox](https://www.mozilla.org/en-US/firefox/), as we all know, is an open-source browser widely used by millions of users, developers, and cybersecurity experts. The software is free to use, and its source code is available to the public. Anyone, all around the world, can make changes to the software and fix bugs. Have you thought about contributing to the Mozilla Firefox browser yourself, whether through code or by writing documentation? If so, here’s each and every step you need to make your first Mozilla Firefox contribution.

## **Mozilla firefox Contribution (4 steps):**

* Getting the Mozilla Firefox source code.
    
* Creating a Bugzilla account.
    
* Making changes to the source code and creating a patch.
    
* Submitting the patch for review using Phabricator.
    

## **How to Get Mozilla Firefox Source Code**

This piece deals with building Firefox on Linux systems (any distro is fine). This is the first step in the Mozilla Firefox contribution. To learn more about building Firefox on another platform, you can click [here](https://firefox-source-docs.mozilla.org/setup/index.html).

To download the source code you have to use [Mercurial](https://www.mercurial-scm.org/) (also known as hg) which is a distributed version control system used for Firefox development.

First, open a new terminal window to download the source code by following the commands below.

```bash
//Create a folder named src and go inside it 
mkdir src && cd src 

//Get the source code 
hg clone https://hg.mozilla.org/mozilla-central
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735732554198/5e5c40ed-320f-4ae5-a88a-d1638b7e50bc.png align="center")

You’ll have to compile the code before you can run it. The compilation process may take hours to complete, so be patient. Also, while compiling the source code you may get various errors. These errors are listed below with the respective commands required to solve them.

To compile the source code:

```bash
//Change directory to mozilla-central 
cd mozilla-central 

//Compile the source 
./mach build
```

## **Possible errors during code compilation**

One of the errors you may get is the `rust compiler` version error. This error occurs when you have an older version of `rust compiler` installed. To solve it, run the command:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733009358/91892e7a-cc69-4d0c-8cac-64f1d76561eb.png align="center")

Another error regards `cbindgen`: Solve it using the following command:

```bash
// Install the latest version of cbindgen
cargo install cbindgen --force
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733031030/1ba21c42-a949-456e-b722-141ac8912722.png align="center")

You may get even more errors depending on the packages which you have installed on your system and whether they are up to date. Those errors can be resolved by following the steps displayed in the terminal window.

After installing the required packages you once again have to compile (build) the source code using the command mentioned above. After a successful compilation of the source code, you’re ready to run the Mozilla Firefox browser by using the following command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733081061/48dd0098-25d2-4125-a686-64eb08f2138b.png align="center")

Successfully build now run the Mozilla Firefox Browser

```bash
//Running the code 
./mach run
```

## **Creating a Patch**

First, you’ll need a [Bugzilla](https://www.bugzilla.org/) account. Create one using your email address or your GitHub account.

## **Choosing your issue**

After creating your Bugzilla account, look for “good first bugs.” These are bugs which are easy to solve and focused on getting beginners familiar with the Firefox source code. After you get familiar with the process and source code, you’ll be able to solve the high-priority bugs. The list of available bugs to solve can be found [here](https://codetribute.mozilla.org/). You can filter bugs according to your expertise and the programming languages you are proficient in.

For this tutorial, we’ll use [Bug 1475503](https://bugzilla.mozilla.org/show_bug.cgi?id=1475503): Stop using preprocessor in `reftest.jsm`, which is the easiest to start with.

Start by reading the information provided by the bug reporter in order to understand the problem. If you still need more information, or you get stuck, you can ask the mentor (reporter) associated with that bug for help.

Whenever you’re solving a new bug, you first have to make sure that the Firefox source code which you have on your system is up to date. You can update your Firefox codebase by running the following command:

```bash
//To update the Mozilla Firefox code base 
hg pull -u
```

Let’s find out what the reporter of Bug 1475503 says about it:

```plaintext
There are two preprocessors in same file at location mozilla-central/layout/tools/reftest/reftest.jsm. The first preprocessor, #ifdef MOZ_ENABLE_SKIA_PDF can be removed from that file and added to the file located at mozilla-central/toolkit/modules/AppConstants.jsm. The second preprocessor can be completely removed. Lastly, the * before reftest.jsm in the mozilla-central/layout/tools/reftest/jar.mn file has to be removed. 
```

## **How to solve Bug 1475503**

First, let’s remove `#ifdef MOZ_ENABLE_SKIA_PDF` from `reftest.jsm`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733117206/7acf1676-3dfd-4548-b7c1-f307a0b677c1.png align="center")

And now add that first preprocessor at the end of the `AppConstants.jsm` file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733122268/dbb42df6-f14a-4176-aaae-9b75a20f8fb5.png align="center")

Second, completely remove the second preprocessor, shown below, from the `reftest.jsm` file.

```java
#ifdef XP_MACOSX 
try { 
var dock = Cc["@mozilla.org/widget/macdocksupport;1"].getService(Ci.nsIMacDockSupport); dock.activateApplication(true); 
} 
catch(ex) { } 
#endif
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733160974/b376f2a9-d7ff-4d55-b5de-c8f6cc54530b.png align="center")

We’ve done the required changes. Next we can build the source code to check whether everything works correctly.

```bash
//Compiling the source code 
./mach build
```

## **Committing the changes**

Up until now, the changes we made have been represented as a patch. Now, we have to commit those changes with a commit message. The commit message must contain the bug number with a short description of that bug.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733181656/661e37d3-ed3a-4882-9f39-3090cfd4ea29.png align="center")

Committing the changes which we made to the code

```bash
//Adding a commit message 
hg commit -m "Bug 1475503 Stop using preprocessor in reftest.jsm"
```

## **Submitting Your Patch for Review**

Finally, you have made some Mozilla Firefox contributions and now its time to send the changes which you have made for review. First, create a Phabricator account by following the [steps here](https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html).

Install [`moz-phab`](https://github.com/mozilla-conduit/review) and [Arcanist](https://secure.phabricator.com/book/phabricator/article/arcanist/) for submitting patches by using this [link](https://moz-conduit.readthedocs.io/en/latest/arcanist-linux.html).

Before submitting the patch for review using `moz-phab`, make sure you run the following command after completing the above two steps. Otherwise, it will give you an error (`moz-phab: command not found`).

```bash
source ~/.profile
```

```bash
moz-phab install-certificate
```

Now you’re ready to submit your patch for review.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1735733217668/ab8473a4-e5a5-4d2a-8c30-8feb0d3d578d.png align="center")

Submitting the changes to the phabricator code review tool

```bash
moz-phab submit
```

## **Resources for Learning More About Open Source**

1. [Open (Source) for Business: A Practical Guide to Open Source Software Licensing - Third Edition](https://amzn.to/3QoWfU6)

2. [Producing Open Source Software: How to Run a Successful Free Software Project](https://amzn.to/49feW58)

Liked our Mozilla Firefox contribution guide then support us on [Patreon](https://www.patreon.com/liongueststudios). Your support will surely help us in writing more of such content.
