Chris Holtz created a very useful little extension called
"Clear Cache Button". Its mere purpose is to provide a button/icon that you can put in your Firefox toolbar and clear both memory and disk caches with a single click of the icon. Unfortunately with the 0.9 versions the extension broke for the MacOSX users that have not installed the
Growl notification framework.
Clicking the Clear Cache button in Firefox in MacOSX logs the following to the Error Console:
uncaught exception:
[Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"
nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"
location: "JS frame :: chrome://clearcache/content/overlay.js :: clearcachebutton_clearCache :: line 7"
data: no]
Looking into the code I've found that the exception is thrown in this line:
var alertService = Components.classes["@mozilla.org/alerts-service;1"].getService(Components.interfaces.nsIAlertsService);
I've looked up the
documentation of the nsIAlertsService interface. From the docs I got that the initial call to
getService()
should complete without error and the call to the
showAlertNotification()
function should throw a
NS_ERROR_NOT_AVAILABLE
exception (they explicitly mention MacOSX here) in case the service cannot display the notification (eg. if Growl is not installed, which is true in my case).
Unfortunately it seems that the Mac implementation of this interface is a bit buggy and already the initialization of
nsIAlertsService
triggers an exception.
So I've surrounded both the
getService()
and the
showAlertNotification()
calls with a try-catch block and now the extension works on MacOSX too. I've not tested it with the Growl framework installed, but I assume that it should display the notifications successfully.
Furthermore I've added the last (optional) parameter to the showAlertNotification() call so MacOSX users can block these notifications in their Growl configuration.
I've attached the modded overlay.js file, a patch/diff file (changes made to the overlay.js found in v0.9b) and the complete packaged extension with the fix incorporated which I've named v0.9b2. You can install it by downloading it to your machine (right-click, Save as) and opening the extension in Firefox via "Open file". Probably you should uninstall previous versions of the extension before you try to install this one (I haven't tried whether installing from a local file could upgrade an existing version or not).
PS: I've already sent the fix to Chris (the developer of the extension) so probably it'll be incorporated in the next official version too.
Comments
Clear Cache Button v0.9f still broken on Mac OS X
So I've taken the current version and patched it again and attached the sources and the patched XPI too.