WebExtensions/Contribution Onramp: Difference between revisions

Jump to navigation Jump to search
Update links (mostly broken MDN links); mention Android-specific xpcshell tests
(“Check-in Needed” is sunset in favor of Lando)
(Update links (mostly broken MDN links); mention Android-specific xpcshell tests)
Line 1: Line 1:
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 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://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Introduction go here].
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://firefox-source-docs.mozilla.org/contributing/contributing_to_mozilla.html go here].


== General Tips ==  
== General Tips ==  
Line 37: Line 37:


== Testing ==
== 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://developer.mozilla.org/en-US/docs/Mozilla/QA/Automated_testing overview of automated testing]. In the WebExtension API code, most tests are either [https://developer.mozilla.org/en-US/docs/Mozilla/QA/Writing_xpcshell-based_unit_tests xpcshell tests] or [https://developer.mozilla.org/en-US/docs/Mozilla/Browser_chrome_tests 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.
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://firefox-source-docs.mozilla.org/testing/xpcshell/index.html xpcshell tests] or [https://firefox-source-docs.mozilla.org/testing/mochitest-plain/index.html (browser-chrome) 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:
The easiest way to get started with tests is to look at existing tests:
Line 43: Line 43:
** toolkit/components/extensions/test/xpcshell/ ([https://searchfox.org/mozilla-central/source/toolkit/components/extensions/test/xpcshell Searchfox link])
** 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])
** 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:
* Browser-chrome tests:
Line 80: Line 81:


ExtensionTestUtils.loadExtension allows you to quickly generate a test extension, and its input parameters are documented at:
ExtensionTestUtils.loadExtension allows you to quickly generate a test extension, and its input parameters are documented at:
https://searchfox.org/mozilla-central/rev/ef8b3886cb173d5534b954b6fb7eb2d94a9473d0/toolkit/components/extensions/ExtensionTestCommon.jsm#185-212
https://searchfox.org/mozilla-central/rev/5f88c1d6977e03e22d3420d0cdf8ad0113c2eb31/toolkit/components/extensions/ExtensionTestCommon.jsm#387-411


Another common action in tests is to load a web page or extension page.
Another common action in tests is to load a web page or extension page.
Line 91: Line 92:
== Submitting a Patch ==  
== Submitting a Patch ==  


For an overview of how to submit a patch, please see [https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/How_to_Submit_a_Patch this page on MDN].  
For an overview of how to submit a patch, please see [https://firefox-source-docs.mozilla.org/contributing/how_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>.
* 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