31 August 2010 - 13:00There’s Always Another Release

As Atul mentioned in “The Social Constraints of Bettering The Web” [toolness.com], Account Manager will likely not make its way into Firefox 4. He points out one of the biggest bottlenecks as getting approval from Firefox product drivers:

Within Mozilla, I see my coworkers vie for the attention of this tiny handful of gatekeepers. People in charge need convincing; the clever social engineer has a lot of power when it comes to navigating this landscape.

This last step of getting approval comes at the very end of a long line of work. While Dan and I have been busy implementing the core feature and making sure it doesn’t regress performance and tests, a good number of people have been involved both inside and outside of Mozilla to design the user interface, to flesh-out the spec and to integrate the feature into sites or as plug-ins.

Alex Faaborg's mockup of letting users pick different types of accounts

But this approval process affects people outside of Mozilla as well. New developers in the community hear about neat features of the upcoming Firefox and want to help by hacking on patches of related features. For example, the status bar removal in Firefox 4 has a number of side-effects including the removal of the download statusbar. Alex Limi has suggested ways for “Improving download behaviors in web browsers” [limi.net], which would add a new toolbar interface, and while there are initial patches from multiple community members, it seems unlikely to make it to Firefox 4.

I even ran into this same roadblock a couple years ago when I was trying to get the AwesomeBar into Firefox 3. Back then I was a random community member that had a good idea and was able to hack on stuff in my “free” (ha! ;) ) time. It was only after a lot of prodding and persistence that got just a bit of what I worked on into Firefox 3, but that was all very stressful as I looked back on “Why I Worked On Firefox.”

But fear not community members! There’s always another release. The product drivers are not approving patches during this beta-crunch time because there’s always some risk involved with changes (especially those “it’s just a one line change” fixes :D ). New changes typically are followed up by a number of new issues and patches that then need to be additionally hacked on, tested, reviewed, and approved. So just because it doesn’t get approval now doesn’t mean it won’t be accepted when the tree is more open.

Additionally, patches usually come with a number of dependent fixes that might be able to land first. And in the case of Account Manager, I’ve already gotten in some changes into Firefox 4 that improve the new PopupNotifications (used by Geolocation and Add-ons) and testing infrastructure. Some other useful changes that could land independently of Account Manager are some upgrades to the Password Manager and networking APIs. So while the core feature might not be in yet, the platform is made better and ready for it.

So keep hacking away and perhaps your feature will be ready to land on the open tree after Firefox 4 branches. And then it’ll have many months to bake and get tested by other community members and eventually be seen by millions of Firefox users. :)

10 Comments | Tags: Account Manager, AwesomeBar, Development, Mozilla

30 August 2010 - 15:31Synchronous and Asynchronous APIs

In designing the Firefox-facing APIs of Account Manager, thunder [sandmill.org] and I decided to make most of the interfaces take a callback/continuation. Two main reasons were 1) to allow add-ons to add extra account types like OpenID and 2) to find out if you’re logged-in to a site over multiple network requests.

For an add-on to provide a new account type, it needs to be able to tell Firefox what saved accounts are available and how to connect to them. These might need to read data from disk and/or network; or perhaps request more information from the user like a 1-time code sent over SMS. For Firefox to support these more-complex interactions, it can’t assume that a method implemented by the add-on can return a value immediately.

Asking for additional information to connect to a banking site

In this particular mockup, the site has told Firefox not to use the basic username-password account type but instead to use an account type that asks for more information. Here, an add-on has already saved the username/password and doesn’t to ask for them, but it can’t immediately connect without asking for more information, so it tells Firefox to show this popup. With the async. API, the add-on can later tell Firefox that it has finished the connect process.

The second reason for going async. overlaps with the first of supporting add-ons; Account Manager and account types need to talk over the network to other machines. These requests can take more than just a few milliseconds, so blocking the rest of Firefox when you click on the “Sign in” button using a synchronous request would be bad. In the case of finding the account status, Firefox might need to make requests for any or all of host-meta, AMCD and the session status.

The Password Manager API in Firefox happens to be synchronous—as are many other interfaces in Firefox. Converting it to be asynchronous for use in the username/password account type was fairly simple, but there’s a couple things to keep in mind: when the work is done and when the result is given.

Implementing the async. interface with the synchronous Password Manager

Here, we’ve made the call to savedAccounts immediately do the work of finding the logins, so this means the caller might have to wait before the asynchronous savedAccounts call returns. We could have just as easily delayed this work to run after the function returns by moving the logic into the async function call, but one needs to be aware that if the arguments are live objects, the contents might change by the time async triggers the callback.

The second point of “when the result is given” is less flexible. The function above could have been written to just call onComplete(accounts) immediately without the async wrapper, but that could break the caller as the implementation is no longer truly asynchronous. The caller would stop working if code is supposed to execute after the call to savedAccounts but before the call to continuation, onComplete.

Trivial example of how non-async. implementations could break

For web developers, implementing async is pretty simple as the global window object has setTimeout. So one implementation could look like function async(callback) setTimeout(callback, 0);

Making the choice of having the APIs be asynchronous does have some drawbacks in terms of code structure. Any function that eventually calls an async. function will be forced to take a callback as well, and if it needs to call multiple async. functions, the logic needs to be broken up into multiple callbacks. If you want to share variables across these callbacks, you’ll end up creating many nested anonymous functions (closures).

Additionally, some simple things like doing Array.reduce (fold), which visits each array item and applies a function to produce a single result, can get pretty complicated if you want to pass in an async. function. In a later post, I’ll describe a way to have asynchronous functions look like they’re synchronous so that you can avoid some of this callback craziness. ;)

No Comments | Tags: Account Manager, Add-on, Development, Labs, Mozilla

1 July 2008 - 5:48Firefox 3 Smart Location Bar Saves You Time

Now that Firefox 3 [mozilla.com] has been downloaded well over 27 million times [mozilla.com], many people have noticed that the Smart Location Bar can find pages that match not only in the URL but also in the title or tags added to a bookmarked page. One commonly overlooked feature that saves you a lot of time is the ability to quickly narrow down the search results and find exactly what you want. Just type another word.

Typing multiple words and not being restricted to just matching at the beginning of the URL to match the domain provides a lot of power to the user.

I’ve put together some examples of how the Smart Location Bar can save you seconds, even minutes, every day when using websites like YouTube or Gmail or any place you can visit through Firefox. (Don’t miss the pro-tip at the end to easily read your new messages in Gmail! :D )


Ever visited a page but don’t remember the site’s URL or even the the domain? When you’re clicking through Google search results, you might find what you’re looking for but forget to make note of the URL. Many times you can just type in what you were searching for and Firefox can find it right away. Firefox will even order the results based on better matches.

Diablo III Results
Easily go back to pages without typing the domain

In most other browsers, you would have to start typing out “www.blizzard.com” if you remembered it and then additionally type “/diablo3″ to find the Diablo III related pages. Using Firefox 3′s Smart Location Bar, you could easily jump to what you want and perhaps find non-Blizzard pages that you might be interested in because you don’t have to remember to type the domain anymore.


A lot of pages on the Internet have URLs that are completely filled with junk — at least totally unmemorable for the user. Most likely the title of the page will have something much more useful. One prime example is YouTube where the video URLs are just some way for YouTube to know which video you want.

You’re more likely to remember the title of the page, which directly relates to the content of the video that you previously watched, than remembering even half of the random characters used to identify the video.

YouTube Results
Quickly find previously viewed YouTube videos

In this case, I was trying to find Wind Garden [youtube.com], an 8-bit remix of a really great song from Super Mario Galaxy. In other browsers, if I wanted to try finding the page from my history and started typing out “yout,” I would never have found it because somebody linked that video to me from nl.youtube.com. I was able to find it with Firefox 3 because “yout” matched in both the title and URL ignoring the “nl.” part.


Another example of the AwesomeBar’s time-saving ability that will be popular with movie watchers is with IMDb – the Internet Movie Database. If you’re like me and can’t remember which movies every actor has been in, you’ll be revisiting this site over and over again. However, instead of always going to to the main IMDb homepage to find a movie using the search box, you can go directly to the page you want with Firefox 3.

IMDb Results
Save time by going directly to movie page

These IMDb results show off yet another strength of the AwesomeBar — being able to match both the URL and title at the same time. Notice that “imdb” only shows up in the url. You can type “imdb” and then a word from the title to quickly narrow down the results to find the exact page you want. This saves you those extra seconds it takes to load the whole IMDb homepage and start a search.


You’ve got phone numbers, account numbers, social security numbers, personal identification numbers, and more numbers to keep track of. There’s no need to additionally keep track of IP addresses for those websites that don’t have easy-to-remember domain names.

Router Results
No need to memorize IP addresses anymore

Cellphones let you easily find phone numbers by Contact name, and Firefox 3 lets you find IP addresses by Page name. Just like how you need to enter the contact name and phone number the first time on your phone, you’ll need to type in the the IP address once. But on the up-side, you don’t even need to provide a name for the IP address because Firefox 3 will automatically remember the page’s title for you. :)


Gmail has done a great job with their newest version by providing multiple points of access to their web application. Each message can be accessed directly by URL instead of requiring the user to first load the main Gmail page then searching for a message.

Gmail Results
Get right to business with rich internet apps

Being able to access these multiple points of entry is facilitated by the AwesomeBar’s match-anywhere functionality. In this case, you would want to match page titles for email titles, but URLs can also be matched for commands like “new doc” for Google Docs [madhava.com].

By combining the AwesomeBar’s adaptive learning [ed.agadak.net] with the ability to start a Gmail search to find unread messages [mail.google.com] plus automatically selecting the first result [addons.mozilla.org] when pressing enter, I’ve been saving a lot of time whenever I check for new messages. All I need to do is type “mail” and press enter.

Digg it! Edit: Updated for post-Firefox 3 launch intro and a couple new examples.

65 Comments | Tags: AwesomeBar, Development, Google, Mozilla, Nintendo

15 April 2008 - 22:45A Different Development Process

It seems that Mercurial and Mozilla have quite different patch/review process, but then again they’re two very different projects. I just found out today that Bug 394650 – Make line numbers linkable when viewing files/annotate for hg.mozilla.org [bugzilla.mozilla.org] was “works for me.” I was confused for a little bit; but yes indeed, annotate/changeset views on hg.mozilla.org have linkable line numbers for each file… just like how I would have coded it. ;)

Turns out that the patch that I sent in to the dev list ended up making it in to Mercurial 1.0 [hg.intevation.org]. No official reviews, no comments. They just checked in the patch to their “crew” (trunk) repository and let it bake for several months. Seems like nobody complained enough to have it backed out and here it is now in Mercurial 1.0 as we can see on hg.mozilla.org.

But this post isn’t about the differences between Mercurial and Mozilla. It’s about the current Mozilla CVS development process vs Mozilla with Mercurial.

One main difference is changesets. Instead of having a separate version number for each file as in CVS, all related changes are grouped together for a changeset. These are the steps one needs to do right now to see all related changes of a patch: 1) use mxr to find the file you’re editing 2) switch to blame to find the checkin 3) click the bug number if provided 4) hope there’s a clearly marked patch as the one checked in to see what else was changed. :(

With Mercurial, you can just look at the changeset which contains everything; e.g., patch to not need to click the page to use gmail keyboard commands [hg.mozilla.org]. Additionally, now with my patch for showing line numbers in changesets, you can link people to a specific line in a patch [hg.mozilla.org]. This could be useful if you need to point to a particular line in a bugzilla comment about why it broke something. Or especially useful with a stack of patches on mq and you’re collecting feedback on it from other people.

Another aspect of changesets is that there’s a “global version” for the whole repository. You can jump back in time to an earlier revision and view the whole repository as it was before a particular patch was checked in. We currently have something like this on a per-file basis with bonsai, but you need to do so much more work to look at “the right version” of other files. E.g., going back to when adaptive learning was checked in [hg.mozilla.org], you can see that the autocomplete was still only emphasizing the first match in the url and title [hg.mozilla.org].

Of course, you can just use the mercurial web interface to view the latest version of the file. Just take http://hg.mozilla.org/cvs-trunk-mirror/index.cgi/file/tip/ and append the file you want. (Normally “tip” would be a changeset/revision hex number, but you can put in “tip” because it’s an alias (tag) for the latest version.) And from there, you can look at the whole patch for the current version (changeset), browse the checkin history of that file (revisions), or look at the blame (annotate) [unfortunately it doesn't have checkin comments on hover yet].

Typing out that whole url might be cumbersome, but good thing we have the AwesomeBar with multi-word search on word boundaries (with camel case) plus adaptive learning. ;) “hg. auto” [hg.mozilla.org]

I’m not sure how distributed the development process will become for Mozilla, but these neat tools provided by default with Mercurial will make it easier to track changes and refer to them in bugzilla comments or over IRC. (Oh, and if you’re using mercurial and haven’t looked into mq yet, you should do so. It’s a great (builtin) extension to track/reorder multiple patches that you’re working on. And for those curious how I send changes for try-server builds, I apply the stack of patches and hg export firstpatch:lastpatch > combined.patch :D )

4 Comments | Tags: AwesomeBar, Development, Mercurial, Mozilla