Categories
Mozilla

Did you know we have a style guide?

I’ve been surprised at the number of people who were unaware that Mozilla has a coding style guide. It contains the rules for new files for both JavaScript and C++. You can save your reviewer a whole bunch of time by making sure your code conforms to this before asking for review.

Categories
Mozilla

NetUtil.jsm Just Got More Useful

Recently, a few bugs have landed enabling a bunch of nice things for consumers of NetUtil.jsm:

  • NetUtil.newURI can take a string (plus optional character set and base URI) or an nsIFile.
  • A new method for creating channels has been created. NetUtil.newChannel can take an nsIURI, a string (plus optional character set and base URI), or an nsIFile.
  • NetUtil.asyncFetch can take an nsIChannel, an nsIURI, a string (plus optional character set and base URI), or an nsIFile.

This means, among other things, that it now requires less code to read a file asynchronously than it does synchronously. The old way to do this asynchronously can be seen here on MDC. This would give the consumer a byte array of the data in the file. Compared to the synchronous case, which can be seen here. Both are pretty verbose and clunky to use. The new way looks like this:


NetUtil.asyncFetch(file, function(aInputStream, aResult) {
  if (!Components.isSuccessCode(aResult)) {
    // Handle Error
    return;
  }
  // Consume input stream
});

One function call, with a callback passed in. There is a slight difference from the old asynchronous method, however. NetUtil.asyncFetch gives the consumer an nsIInputStream instead of a byte array. The input stream is a bit more useful than a raw byte array, although it can be painful to use in JavaScript at times (maybe we need an easy method to convert an input stream to a string?). I look forward to patches using this method to read files instead of doing it synchronously.

Categories
Mozilla

Bugzilla Helper 0.3.0

Version 0.3 of the Bugzilla Helper Add-on for Thunderbird has been released! Current users will have to update manually since sandboxed add-ons do not automatically update. New in this version:

  • Use version 0.3 of the REST API.
  • Enable spell checking in the comment field.
  • Allow replying to New: bugmail.
  • Offline support.

Found a bug? E-mail me or leave a comment.

Categories
Mozilla

Bugzilla Helper 0.2.0

I just uploaded Bugzilla Helper 0.2.0. This improves on the last release by making making the submission of comments an asynchronous operation. It also uses the activity manager in Thunderbird to track the process of the submission, and retry it if an error occurs.

There are still some apparent issues with the REST API that the add-on is using, and I’ll likely include some workaround in upcoming versions. 0.2.0 is available on addons.mozilla.org and is a recommended upgrade. Current users will have to update since sandboxed add-ons do not automatically update.

Categories
Mozilla

Crash! Boom! Bang! But I just wanted to delete some history…

If you’ve been experiencing crashes when trying to delete a large set of history, I have great news for you! We’ve identified the issue, and a fix will be coming to you shortly!