There are two main ways to do this:
Bugzilla: where tasks are tracked, patches attached, and reviews sought and given (here's an example).
Lots of communication happens on irc.mozilla.org. Newcomers and oldcomers are welcome in #introduction
.
Other popular channels:
#developers
- high traffic, general Gecko-related development#jsapi
- JavaScript engine development#gfx
- graphics/rendering discussion#content
- DOM implementation#fx-team
- Firefox frontend development#necko
- Networking stack development#mobile
- Firefox for Android development#b2g
- Firefox OS developmentreview?
flag to the attachment, targetted at your mentor (or someone mentioned a lot in hg log
).review+
, it's ready to be committed.review+
(known as r+).#introduction
is a very helpful place for these kinds of questions.
There's a wiki page that has everything you need.
However, to show how easy it can be:
wget --no-check-certificate https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py && python bootstrap.py
hg clone https://hg.mozilla.org/mozilla-central
./mach build
obj-x86_64-unknown-linux-gnu/dist/bin/firefox -no-remote -P
Full builds can take anywhere from 15 minutes (on really expensive, good hardware) to 1-2 hours (on not very good hardware).
It's often not necessary to rebuild everything!
./mach build [dir1] [dir2...]
./mach build browser/
(super-fast)./mach build toolkit/ browser/
(often quite fast)./mach build topdir/ toolkit/library
If your changes don't seem to be showing up, ./mach build
to be safe.
We have a lot of tests, and a lot of testing frameworks.
./mach mochitest-plain
: web content tests./mach mochitest-chrome
: web content tests with elevated privileges./mach mochitest-browser
: browser UI tests with elevated privileges./mach mochitest-a11y
: accessibility tests./mach reftest
: rendering/layout comparison tests./mach crashtest
: tests that don't crash./mach xpcshell-test
: JS-only tests that run in a limited environment (eg. no DOM)Almost all of these can be passed a particular test file to run.
See the automated testing wiki page for a more in-depth discussion.
Ask your mentor to submit your patches to our build farm for testing.
You can also (and should!) request limited commit access to do so yourself.
call DumpJSStack()
to see the current JS code on the stackac_add_options --enable-debug
ac_add_options --disable-optimize
debugger;
JS statement will dump the current JS stack to stdoutprintf
for C++, dump("foo")
/Components.utils.reportError("foo")
for JSLearning more about the internals of web browsers will help your understanding of Gecko's internals and the organization of Firefox's source code.
MXR is your friend.
Recommended learning/searching strategies:
#introduction
Lots of IDL interfaces implemented by JavaScript and/or C++ code.
[scriptable, uuid(d32b87b3-fe96-4f42-81ab-2f39f7ec43ff)]
interface nsIGeolocationProvider : nsISupports {
/**
* Start up the provider. This is called before any other
* method. may be called multiple times.
*/
void startup();
/**
* watch
* When a location change is observed, notify the callback. The privacy
* argument informs the provider whether the initiating request came from
* a private context; it is up to the provider to use that information
* in a sensible manner.
*/
void watch(in nsIGeolocationUpdate callback, in boolean requestPrivate);
/**
* shutdown
* Shuts down the location device.
*/
void shutdown();
/**
* hint to provide to use any amount of power to provide a better result
*/
void setHighAccuracy(in boolean enable);
};
eg. nsIChannel
provides common interface for
nsHttpChannel
(http://)nsFtpChannel
(ftp://)nsFileChannel
(file://)eg. nsIGeolocationProvider
provides interface for
NetworkGeolocationProvider
, JS component that initiates an XMLHttpRequest to Google's serviceGonkGPSGeolocationProvider
, C++ component that uses hardware GPSXPCOM types require special smart pointers,
nsCOMPtr<nsIFoo>
nsRefPtr<nsConcreteFoo>
Concrete types can implement more than one interface; use QueryInterface
/GetInterface
to discover them.
JS:
try {
var httpChannel = channel.QueryInterface(Components.interfaces.nsIHttpChannel);
} catch (x) {
}
C++:
nsCOMPtr<nsIHttpChannel> httpChanel = do_QueryInterface(channel);
if (httpChannel) {
}
All XPCOM components are accessible through GetService
/CreateInstance
.
C++:
nsCOMPtr<nsIGeolocationUpdate> geoSvc = do_GetService("@mozilla.org/geolocation/service;1");
nsCOMPtr<nsITimer> geoSvc = do_CreateInstance("@mozilla.org/timer;1");
JS:
try {
var geoSvc = Components.classes["@mozilla.org/geolocation/service;1"].getService(Components.interfaces.nsIGeolocationUpdate);
var timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer)
} catch (x) {
}
They're not weird, just different.
nsAString
, nsACString
- abstract string interfaces for wide and narrow stringsnsString
, nsCString
- concrete string types with storage on heap. Use .get()
to obtain pointer (eg. for printf("%s")
)nsAutoString
, nsAutoCString
- concrete string types with small storage inline, automatically move to heap if outgrownNS_LITERAL_STRING("fos")
, NS_LITERAL_CSTRING("dem")
- just accept it and move onNS_ENSURE_SUCCESS(rv, rv)
- check whether rv
is a success code; if not, complain loudly to stdout and return rv
earlynsresult rv = foo->DoSomething();
NS_ENSURE_SUCCESS(rv, rv);
rv = foo->DoSomethingElse();
NS_ENSURE_SUCCESS(rv, rv);
getter_AddRefs(someCOMPtr)
- XPCOM functions return values through outparams (ie. foo(&someValue)
), and this is usually the correct way of passing themnsCOMPtr<nsIFoo> fooPtr; // fooPtr is null by default
DoSomething(getter_AddRefs(fooPtr));
// fooPtr may now be non-null
You now know much more than most people who see Mozilla's code for the first time.
Your turn.
Remember: when in doubt, ask someone! The Mozilla community awaits you.
/
#