Mozilla XPCOM Learning Lab
Here is another fine presentation for learning XPCOM from Mozilla in my Open Source program at Seneca College. This lab guides you through the process of creating an extension as part of the mozilla build. You can also build extensions as a separate XPI installer which we did in a previous lab and I posted on by inflicting a tabbing behaviour that opened new tabs to the left of the current tab instead of the right hand side.
The Extension in Action
Above, is a picture of the extension that was added to the Firefox build. Actually, the XPCom class that we built only has 1 attribute which a getter/setter are made and a method called add( ) which takes two number parameters and adds them together. Also, when those methods/properties are called upon, they produce output into the debugging log which is what you see in the command line output at the bottom of the picture. Seems simple yes!… Why did it take me a week to figure it out then.
Lost in File path Jungle
One of my reasons for taking so long with this is due to the fact that when the lab was originally written, the place where the header files for the automatically created XPCom object had moved since then. They are now stored in a different place. This was discovered when we asked the instructor in class and he pointed this out. It didn’t mean that we still weren’t stumped on trying to navigate our way around.
Contributions to the Learning Wiki
In order to rectify where the heck the files were being created automatically in the lab, I had to straighten out the wiki page that hosted this lab assignment. My teacher invited it to be updated when we found the error, so just recently I went in and did that.
Essentially, in the lab, it was stating that the header files would be placed in a directory that was no longer being created within “$(moz_obj)/dist/include/{noLongerUsedDirectory}”. So I went through the article and made changes as they appear in the image above.
All of the files that were dynamically created were in the mozilla source code directory and then inside the object directory where all of your compiled object files are stored. The difference now is the in the “dist/include/” directory it now has an alias to the header file. The actual header file is placed in “extensions/{extensionName}/public/_xpidlgen/”. So I went through the lab and made changes to the file paths to reflect those changes. Hopefully this will help clear things up for others in subsequent courses.
Oh ya, Install the Extension!
Ok, so I needed help from my instructor and got some ideas on why my code wasn’t working. First thing that he had me check was to see if the extension was installed. At that moment I recognized a void in my thinking…. I realized I had not even thought that this extension would need to be installed at all. I figured… its built in the source code and compiled with Firefox. I thought it’d be installed automatically. Not the case!
So for the sake of sharing this simple little tidbit with others, maybe it’ll help make more sense of extensions that are built in the browser. Also note… the Extension Developer extension will give you that javascript shell that the lab will need too.
Filed under: open source | Leave a Comment



No Responses Yet to “Mozilla XPCOM Learning Lab”