CP3108B: Final Report
My initial proposal consists of 3 bug fixes:
1. Bug 472483 – Make use of activity manager for calendar operations.
2. Bug 260121 – Make datepicker and timepicker keyboard accessible.
3. Bug 242112 – Make calendar keyboard accessible.
However, due to the complexity of the task and lack of experience working in the open source community, I was unable to complete the proposed items. Nonetheless, I have strived to pick up as much as I can over the semester and accomplish whatever I can.
During the course of the semester, I have made 4 bug fixes (1 is resolved and 3 of them are still waiting for review) and the 5th one is currently in progress.
Despite not being able to complete the proposed tasks, I look forward to working on them after the semester and contribute more to the community.
1. Bug 729526 – suite/browser/nsBrowserContentHandler.js contains unnecessary constant
Work done:
Removed a line of code from /suite/browser/nsBrowserContentHandler.js.
Lessons learnt:
Despite being an easy bug fix, I had learnt quite a bit on how to contribute in the Mozilla community. For instance, it is after working on this bug that I understood the patch submission process – upload patch file and get it reviewed. I also received feedback on how I should be creating a patch with the necessary metadata for check-in. Coming from a Git background, I was under the impression that a git diff -p -U8 would generate the necessary patch file. However, since Mozilla build is managed using Mercurial, I had to find an equivalent command for doing that. I was fortunate enough to receive some help from my mentor and he helped me out by finding the appropriate command to perform the task.
Personally, this task has helped me to gain confidence working on subsequent bugs as I had a hard time trying to resolve another bug – 472483 earlier.
Status:
Resolved and fixed.
2. Bug 734134 – test_simpleThread.html is() calls miss message parameter
Work done:
Added message parameters to test assertion calls.
Code sample:
var worker = new Worker("simpleThread_worker.js"); worker.addEventListener("message", function(event) { is(event.target, worker, "Expected event target for message"); switch (event.data) { case "no-op": break; case "started": is(gotErrors, 2, "Number of errors received before 'started' message"); worker.postMessage("no-op"); worker.postMessage("stop"); break; case "stopped": worker.postMessage("no-op"); SimpleTest.finish(); break; default: ok(false, "Unexpected message: " + event.data); SimpleTest.finish(); } }, false); var gotErrors = 0; worker. function(event) { event.preventDefault(); is(event.target, worker, "Expected event target for 1st error"); is(event.message, "uncaught exception: Bad message: asdf", "Expected 1st error"); ++gotErrors; worker. function(otherEvent) { otherEvent.preventDefault(); is(otherEvent.target, worker, "Expected event target for 2nd error"); is(otherEvent.message, "Components is not defined", "Expected 2nd error"); ++gotErrors; worker. function(oneMoreEvent) { ok(false, "Worker had an unexpected 3rd error: " + oneMoreEvent.message); SimpleTest.finish(); }; }; };
Lessons learnt:
This involves refactoring the existing code and adding additional messages to the code. This bug fix is also trivial. However, this gave me the opportunity to dabble in writing tests for SeaMonkey and understand how the backend infrastructure works.
Status:
Waiting for review from mentor.
3. Bug 735333 – Use Services.prefs instead of preferences-service / gPrefService, in SeaMonkey code
Work done:
Deprecated getService calls and replace them with Service.prefs.
Code sample:
/* * Code sample truncated due to its sheer size – 100 lines changed. */ function AddDirectoryServerObserver(flag) { if (flag) { Services.prefs.addObserver("ldap_2.autoComplete.useDirectory", directoryServerObserver, false); Services.prefs.addObserver("ldap_2.autoComplete.directoryServer", directoryServerObserver, false); } else { var prefstring = "mail.identity." + gCurrentIdentity.key + ".overrideGlobal_Pref"; Services.prefs.addObserver(prefstring, directoryServerObserver, false); prefstring = "mail.identity." + gCurrentIdentity.key + ".directoryServer"; Services.prefs.addObserver(prefstring, directoryServerObserver, false); } }
Lessons learnt:
This bug is not trivial as it sounds. Besides replacing the function calls, I have to read through the code and find out the available libraries that can be called using Services.prefs. After speaking to my mentor regarding this bug, I have also learnt how both approaches differ from each other. Previously, the only way to use Services is to specify one particular service and instantiate immediately using getService. However, this behavior may not be desired for most cases as the service may not be required throughout program runtime. As such, Services.prefs provides the “lazy-getter” approach by allocating the service when needed.
In addition to this, I have also read up on how XPCOM works. XPCOM is a cross platform component object model that forms the core components of Mozilla products. It allows developers to implement features in various different languages using JavaScript, Python and C++. Initially, I was curious as to how we can make simple JavaScript calls to manipulate UI elements in Thunderbird and I understood now that this is possible due to XPCOM.
Status:
Waiting for feedback from mentor.
4.Bug 741019 – a trailing slash in a CSP source host causes it to be ignored (per spec), this should be logged with a CSPWarning()
Work done:
Added conditional statement to check for trailing slash in hosts string. Added additional test case for this check.
Code sample:
/* * In content/base/src/CSPUtils.jsm: */ CSPHost.fromString = function(aStr) { // truncated // host string must be LDH with dots and stars. var invalidChar = aStr.match(/[^a-zA-Z0-9\-\.\*]/); if (invalidChar) { // host string with a trailing slash is a possible common error, // do an additional warning in this case if (invalidChar == '/' && aStr.indexOf(invalidChar) == aStr.length - 1) { CSPWarning(aStr + " will be ignored due to trailing slash"); return null; } CSPdebug("Invalid character '" + invalidChar + "' in host " + aStr); return null; } /* * In content/base/test/unit/test_csputils.js: */ h = CSPHost.fromString("foobar.com/"); do_check_eq(null, h); // "trailing slash in hosts should fail"
Lessons learnt:
This bug is tougher than the previous ones. I had to refresh my memory on regular expressions and understand what the code is trying to do. After some discussion with the mentor, I also had to implement a test for the fix I worked on. This requires some reading up on xpcshell tests and how to run them. Overall, this was a great learning experience for me.
Status:
Waiting for review from mentor.
5.Bug 472483 – Make use of activity manager for calendar operations
Requirements:
Display calendar operations (i.e. add/delete/modify events, to-do items) in the Activity Manager interface (see picture below) in Thunderbird.

Work done:
Understood the code architecture for Thunderbird Calendar extension. Read up on how event notification is integrated in the code. Came up with skeleton code for the new framework.
Lessons learnt:
Personally, I was stuck at this bug for quite some time. Since this was the first one that I worked on, it was a daunting task. Nonetheless, I spoke to the mentor and learnt quite substantially on the code base. The initial plan is to add activity manager code at places where calendar operations take place. However, my mentor commented that this is undesirable as this would introduce coupling and violate the MVC pattern. Instead, he proposed creating an API class for activity manager to handle calendar operations separately. It should also observe calendar operations for changes.
I hope to continue working on this after the semester given that I have a better picture on how to implement this.
Status:
In progress.
Conclusion
My semester has been really fruitful after taking up this module. Open source contribution has been something that I have wanted to do for some time and I am glad that I took up this module. In addition to learning how the open source community works, I have also learnt the code base of Thunderbird’s Calendar extension, understood how XPCOM powers Mozilla components and applied some of the concepts that I have learnt in school such as observer and MVC patterns.
Looking forward, I hope to apply what I have learnt here and work on bigger projects in future.
