Changes

Jump to: navigation, search

WebExtensions/Contribution Onramp

2,316 bytes added, 19:50, 10 September 2018
Testing: more info
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.
 
A test consists of multiple subtasks, which are defined in the test files via add_task(...).
Most tests have the following minimal structure:
 
add_task(async function someShortAndSimpleDescriptionHere() {
// Define a test extension.
let extension = ExtensionTestUtils.loadExtension( .... );
 
// Loads the actual extension.
await extension.startup();
 
// Tests here, often using extension.sendMessage and/or extension.awaitMessage
 
// Unload the extension and remove the temporary files.
await extension.unload();
});
 
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
 
Another common action in tests is to load a web page or extension page.
In xpcshell-tests, use ExtensionTestUtils.loadContentPage.
 
In browser-chrome tests, the BrowserTestUtils namespace provides many useful test helpers, such as BrowserTestUtils.openNewForegroundTab to open a new tab. BrowserTestUtils is implemented and documented at https://searchfox.org/mozilla-central/source/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm
 
== 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].
 
* When you are ready to have your patch reviewed, submit your patch to [https://moz-conduit.readthedocs.io/en/latest/phabricator-user.html Phabricator]:
** First, install the [https://phabricator.services.mozilla.com/book/phabricator/article/arcanist_quick_start/ arc tool].
** Then, use [https://moz-conduit.readthedocs.io/en/latest/arcanist-user.html these instructions] to submit the patch. Choose your mentor as the reviewer.
** Note that you may go through a few iterations before your code is ready to go.
* When the patch is approved, add the keyword “checkin-needed” to the bug on Bugzilla. If you cannot add the keyword, please ask your mentor to add it for you.
* QA will verify your patch after it lands, unless your mentor has added a “qa-not-needed” keyword.
* Once your patch is accepted, you can expect to see your code in an upcoming version of Firefox!
1,698
edits

Navigation menu