http://developer.mozilla.org/En
I. Web Page
Main page
http://developer.mozilla.org/en/Extensions
1, Set development environment
http://developer.mozilla.org/en/Setting_up_extension_development_environment
2, Build extension
http://developer.mozilla.org/en/Building_an_Extension
3, Install extension
http://developer.mozilla.org/en/Installing_extensions
4, Related resource
1), XUL
A
B http://developer.mozilla.org/en/XUL
2), XUL DOM
A Details
http://developer.mozilla.org/en/DOM
B XUL elements
http://developer.mozilla.org/en/XUL_Reference
3), HTML
A
B
C
4), DOM
I) HTML DOM
A
B
II) XML DOM
A
5) Events
A HTML Events
interact/scripts.html#h-18.2.3
6) Javascript
http://developer.mozilla.org/en/JavaScript
5, Code snippets
http://developer.mozilla.org/en/Code_snippets
7, Others
1) Call external libraries in XPCOM components. https://developer.mozilla.org/en/Using_Dependent_Libraries_In_Extension_Components
II Components
1, XPCOM
1) Main page
http://developer.mozilla.org/en/XPCOM
2) Internal String Guide
http://developer.mozilla.org/en/XPCOM_string_guide
1) Full-scale knowledge
http://developer.mozilla.org/en/Creating_XPCOM_Components
2) Build & Install
A Build Javascript XPCOM
http://developer.mozilla.org/en/Creating_XPCOM_Components
B Build C++ XPCOM under gecko library
a) Build XPCOM under gecko 1.8 & 1.7
b) Build XPCOM under gecko 1.9
C Build XPCOM under Mozilla build system(Source code)
http://developer.mozilla.org/en/Creating_Custom_Firefox_Extensions_with_the_Mozilla_Build_System
3) XPCOM API reference
http://developer.mozilla.org/en/XPCOM_API_Reference
4) Tool to list all components
http://xpcomviewer.mozdev.org/
5) Observer Notifications
http://developer.mozilla.org/en/Observer_Notifications
6) Gecko SDK download
A. Gecko sdk
ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/releases/mozilla1.8b1/
B. XULRunner
2 Necko
A http://developer.mozilla.org/En/Necko
B http://developer.mozilla.org/en/The_Necko_HTTP_module
3 XPIDL
http://developer.mozilla.org/en/XPIDL
4 XPCOM Glue
https://developer.mozilla.org/En/XPCOM_Glue
III. Others
1, About protocols
http://blog.cathayan.org/item/1634
2, Firefox command line arguments
3, Firefox Profile
1) Profile folder
A
B
2) Specify profile
3) Use multiple profile
IV. Example
1, HelloWowld
http://blogimg.chinaunix.net/blog/upfile2/080916110338.zip
2, FireKeeper
http://firekeeper.mozdev.org/
3, ClamWin
4, McAfee SiteAdvisor
http://mcafee.com/cn/small/products/web_security/siteadvisor.html
V Debug hints on linux
(Referen to
https://developer.mozilla.org/En/Troubleshooting_XPCOM_components_registration
to get more information about debug hints on other platform)
- Use strace to see if Firefox is trying to load your components: a) run firefox using the command 'strace firefox 2>&run.log'; 2) Check content near to you component XXX.so)
- Check if you have missing dependent libraries:
- From your Firefox (/XULRunner) install directory, run "./run-mozilla.sh `which ldd` -r path/to/your/component.so". There should be no "not found" entries and no undefined symbols. (The -r switch from GNU ldd lists function relocations; adjust as suitable for your version)
- Pass the
-Wl,-zdefs
flag to gcc when linking
your component. This will ensure that undefined symbols show an error
at link time instead of failing at run time.
VI Trouble Shooting
1, Components can't be registered
If XPCOM cpmponent can't be loaded, Firefox will simply ignore the problem with no error
messages.
1) Check generated xpti.dat in sub-directory of /home, /root, and firefox path, if XXX.xpt is not added to xpti.dat, we can determine xxx.so and xxx.xpt are installed to wrong place. The components path for all user is different for different platforms:
DevicesBroser Type Component Path
Usually Firefox /usr/lib/firefox-xxx/components
n810 MicroB /usr/lib/microb-engine/components
asus901 Firefox /opt/firefox/components
aigo CoolFox /ust/lib/firefox-xxx/components
2) Check generated compreg.dat in sub-directory of /home, /root, and firefox path, if XXX.so is not added to compreg.dat, we can determine xxx.xpt and xxx.so are installed to the correct place, but xxx.so contains some faults:
A) Incompatible version of SDK is used to compile the component,
Versions of Gecko are
Gecko version | Applications based on it |
Gecko 1.9.1 (under development) | Firefox 3.1, Thunderbird 3.0, |
Gecko 1.9 | Firefox 3 |
Gecko 1.8.1 | Firefox 2, Thunderbird 2, SeaMonkey 1.1 |
Gecko 1.8 | Firefox 1.5, Thunderbird 1.5, SeaMonkey 1.0 |
Gecko 1.7 | Firefox 1.0, Thunderbird 1.0, Nvu 1.0, Mozilla Suite 1.7 |
You'd better build mozilla (Firefox, MicroB, etc.) source code to get SDK(headers, libraries, and tools), (the common steps to build mozilla are: a) mkdir install_dir; b) ./configure --disable-tests --enable-application=browser --prefix=$PWD/install_dir; c)make; d)make install; then all files are copied to $PWD/install_dir)
B) External dynamic libraries called in components can't be loaded in run-time (External libraries contains bugs, or the path of external libraries is not invisible, maybe LD_LIBRARY_PATH has been overrided by browser,such as MicroB, so rather than export library path to LD_LIBRARY_PATH, you'd better add library path to /etc/ld.so.conf, then execute 'ldconfig')
3) xpti.dat and compreg.dat is not removed, please find those files from /home, /root, and firefox path, then remove them
4) .autoreg is not created
5) Browser is broken (specially, some shared libraries used by browser are broken)
2, Firefox crushes
Components contains bugs, you can solve this issue by removing xxx.xpt and xxx.so.
3, XPCOM interface return NS_ERROR_NOT_INITIALIZED
1) Make sure libxpcom.so is not linked
2) For gecko 1.7 and 1.8, -DXPCOM_GLUE is added to CFLAGS, and -lxpcomglue is added to LIBS(also you can build as gecko 1.9); for gecko 1.9, -lxpcomglue_s and -lxpcom are added to LIBS.( please refer https://developer.mozilla.org/En/XPCOM_Glue to get details about linking rules)
3) Firefox SDK is incompatible.
3, XPCOM API Description
1) getter_AddRefs
nsCOMPtr
servMan;
nsresult rv = NS_GetServiceManager(getter_AddRefs(servMan));
Above code is equal to:
nsIServiceManager* servMan;
nsresult rv = NS_GetServiceManager(&servMan);
4, Let component is initialized once the application is launched.
Add the component to the category of "app-startup"(via AddCategoryEntry
of interface nsICategoryService
) in the component register function. Please refer to "http://developer.mozilla.org/en/Creating_XPCOM_Components/Starting_WebLock" to get more details about nsICategoryService.
4, Use componets
1)
Error message:
Type error: Components.classes[cid] has no properties!
Solution:
The component is not registered, or registered failed.
2)
Error message:
Could not convert javascript argument (Null value cannot be used for a (tt reference type) ns result 0x8057000b
Solition:
Maybe, other abnomal componet influences the component to be used.
5, Compiling XULRunner;
Error message:
TestXMLExtras.o:(.data._ZTV11nsIDocument[vtable for nsIDocument]+0x58):
undefined reference to `nsINode::GetProperty(unsigned short, nsIAtom*,
unsigned int*) const'
Solution:
add flags '--disable-tests' when execute configure
6,
Error Message:
When building component for Firefox-2.0.0.14 with compiling flags -DXPCOM_GLUE, linking flags -Wl,zdfs, libs -lxpcomglue, following error message display:
undefined reference to 'NS_NewGenericModule2(............)'
Sulution:
Remove compiling flags -DXPCOM_GLUE, and libs -lxpcomglue. Add libs -lxpcomglue_s , -lxpcom, and -lnspr4
7,
Replace stream listener tee when browser is open(the component is initialized),and restore to original tee when browser is closed(Please read FireKeeper source code to get more details), but when the browser will crush when it is closed(The issue doesn't occur on Firefox 3.0.3 and 3.0b1).
Sulution: Don't restore to original stream listener tee when browser is closed, the browser will restore it automatically, you can observe that via XMCOMViewer.
8, Use non-script type in .idl
[scriptable, uuid(xxxxxxxxxxxxxxxxxxxx)]
interface IXXXComponent : nsISupports
{
[noscript] long MyFunc(in voidPtr pData, in long lDataLen);
};
download each verison of products under Mozilla: ftp://ftp.mozilla.org/pub/mozilla.org/
such firefox ftp://ftp.mozilla.org/pub/mozilla.org/firefox