WebExtensions/Contribution Onramp

From MozillaWiki
< WebExtensions
Revision as of 19:45, 10 September 2018 by Caitmuenster (talk | contribs) (→‎Testing: testing)
Jump to navigation Jump to search

If this is your first contribution to the Firefox codebase, welcome! It can be scary to get started contributing to a large and complex codebase, but we’ve prepared some tips to help you fix a good-first-bug and land a patch in Firefox.

If we haven’t addressed your question in this document, please ask us by leaving a comment in the bug or by joining us on irc.mozilla.org in the #webextensions channel. For a general overview of how to contribute to Firefox, please go here.

General Tips

  • To make sure your comment in Bugzilla is seen, please “needinfo” the bug’s mentor by checking the box that says “Needs more information from” and then selecting “mentor” from the drop down box.

Introduction & Setting Up Developer Environment

  • If you haven’t done already done so, set up your development environment by building Firefox. There are two ways to do this:
    • [recommended] Build Firefox using Firefox Artifact builds. If the issue only requires changes to privileged JavaScript code, we recommend you use this method. Artifact builds saves time because it downloads a pre-built version of Firefox sources and applies your local changes on it, instead of rebuilding all of the C++ and Rust pieces from scratch.
    • Build Firefox from scratch. Note: doing this can take some time. After the initial build, you can build Firefox using the “mach build” command.
  • Next, use Searchfox to quickly find the code associated with your bug.

WebExtensions APIs

You can learn more about how WebExtensions internals are organized and how to work on them by reading this internal API documentation and the WebExtensions Hacking wiki.

Testing

In order to land code in Firefox, you will need to create tests for your patches. For an overview of the different test systems Firefox uses, please see this overview of automated testing. In the WebExtension API code, most tests are either xpcshell tests or browser chrome tests. Xpcshell tests are preferred because of the lower overhead. Browser tests need to be written when a test interfaces with browser UI, such as tabs or context menus.

The easiest way to get started with tests is to look at existing tests:

  • Browser-chrome tests:

These tests can be run with the “mach test” command. To run a specific test, use “mach test [paths to test files or directories]”.

Add your test to an existing file when it is small and fits in that test. Otherwise, create a new test file, and register the test file in one of the .ini files in the same directory as your test, usually browser-common.ini or xpcshell-common.ini.