Changes

Jump to: navigation, search

WebExtensions/Contribution Onramp

301 bytes added, 11:51, 10 May 2022
Update links (mostly broken MDN links); mention Android-specific xpcshell tests
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 chat.mozilla.org in the #addons room (see [[Matrix]]). For a general overview of how to contribute to Firefox, please [https://developerfirefox-source-docs.mozilla.org/en-UScontributing/docs/Mozilla/Developer_guide/Introduction contributing_to_mozilla.html go here].
== General Tips ==
== 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 [https://web.archive.org/web/20210308052053/https://developer.mozilla.org/en-US/docs/Mozilla/QA/Automated_testing overview of automated testing](needs update - [https://bugzilla.mozilla.org/show_bug.cgi?id=1736870 bug 1736870]). In the WebExtension API code, most tests are either [https://developerfirefox-source-docs.mozilla.org/en-UStesting/docsxpcshell/Mozilla/QA/Writing_xpcshell-based_unit_tests index.html xpcshell tests] or [https://developerfirefox-source-docs.mozilla.org/entesting/mochitest-USplain/docs/Mozilla/Browser_chrome_tests index.html (browser -chrome tests) mochitests]. 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:
** toolkit/components/extensions/test/xpcshell/ ([https://searchfox.org/mozilla-central/source/toolkit/components/extensions/test/xpcshell Searchfox link])
** browser/components/extensions/test/xpcshell/ ([https://searchfox.org/mozilla-central/source/browser/components/extensions/test/xpcshell Searchfox link])
** mobile/android/components/extensions/test/xpcshell ([https://searchfox.org/mozilla-central/source/mobile/android/components/extensions/test/xpcshell Searchfox link])
* Browser-chrome tests:
ExtensionTestUtils.loadExtension allows you to quickly generate a test extension, and its input parameters are documented at:
https://searchfox.org/mozilla-central/rev/ef8b3886cb173d5534b954b6fb7eb2d94a9473d05f88c1d6977e03e22d3420d0cdf8ad0113c2eb31/toolkit/components/extensions/ExtensionTestCommon.jsm#185387-212411
Another common action in tests is to load a web page or extension page.
== Submitting a Patch ==
For an overview of how to submit a patch, please see [https://developerfirefox-source-docs.mozilla.org/en-UScontributing/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch this page on MDNhow_to_submit_a_patch.html How to submit a patch]. In short:
* Create a commit with a meaningful commit message, for example <code>Bug [bug ID here] - [short description of patch here] r=[reviewer name here]</code>.
44
edits

Navigation menu