Solving XUL Permission Denied Exceptions
Our company has a XUL-based CRM-ERP application that I maintain. Like most applications we run into bugs from time to time. We’ve had an ongoing battle with some very annoying permission denied exceptions. The exact error varies but it’s always in the form “Permission denied to [accessing|get|set property] XULElement.something”. Here are some examples:
- Permission denied accessing XULElement.parentNode
- Permission denied to get property XULElement.selectedIndex
This past week we encountered one that had something to do with XULElement.childNode but I don’t remember the exact exception. For us these errors only show up after upgrading Firefox and almost always have something to do with trees. This one appeared after upgrading from Firefox 3.0.7 to 3.0.8. This is the third time I can remember these exceptions distrupting our app. There is almost nothing published on the internet about the issue and debugging a complex app without much incite can be a nightmare.
Fortunately I figured out what was going on! The root of the problem stems from bugs in the app’s Javascript. When a sequence of events occurs, say reloading a tree’s data from the server, other data is removed or reloaded. Due to a variable not being reset the JS that handles our trees attempts to access a child node that no longer exists.
It’s all well and good to find the bugs and fix them but why do these errors show up after Firefox updates? My speculation is that it results from improvements to the XUL core. It seems that, by default, these types of errors have been gracefully ignored. The missing elements were just passed over without generating an exception. As the XUL team improves their code they are adding additional, proper error handling by throwing exceptions for these events. While an exception should be thrown, adding them in at a later time can wreck havoc to existing code. In our case these exceptions break the application since it halts JS execution and the whole thing needs to be reloaded.
Our policy has been to insist on a Firefox version freeze, disallowing updates until we’ve had time to review and test each one. This is an unfortunate policy since new versions are released for good reasons (security patches, speed improvements, etc). While I’ve been actively pursuing these bugs and squashing them as they pop up I’m not sure what else I can do short of wrapping everything in try catch blocks. It would be nice if the Firefox changelog was more detailed, allowing me to actively seek out problems before they arise.
In: Web Development · Tagged with: CRM, ERP, Javascript, XUL
