Saturday, September 20, 2008

Error page quirks in IE and Chrome

Here's another quirk of Internet Explorer and Chrome, the documentation of which is tough to find anywhere. In implementing the 404 error page on Resin, I came across a weird situation where FF, Opera and Safari would display the error page correctly but IE and Chrome would display their own error pages. This led to quite some frustration, having checked and rechecked all of the application and resin settings over and over.

It turned out that the only reason for this was that the size of the custom error page I had designed was lower than the threshold set by IE and Chrome for the 404 page. Basically, the error pages must be greater than 512 bytes to be viewable on all browsers. For IE, the settings of the error pages are stored in the registry at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\ErrorThresholds
The following image shows the registry entries for the various error codes in RegEdit:


The setting in Chrome (for 404) is tied into the source code and can't be modified just as easily. Check out the comment in this source code of Chrome around line 259.

// If it's a 404 page, we wait until we get 512 bytes of data before trying
// to load the document. This allows us to put up an alternate 404 page if
// there's short text.

Surprising that Chrome had this setting as well, especially considering that Safari also uses the same WebKit HTML and CSS rendering engine and it doesn't exhibit this quirk.

Cheers.

Wednesday, September 17, 2008

Reading Chrome's bookmarks in java

Google recently released Chrome, a browser based on WebKit (the same one used by Safari). The user interface is quite pleasant and so is its functionality. A few improvements need to be made (for eg.: addition of plugins, RSS feed reader, autofill in textboxes) before it endears itself to techies and common users. Its V8 engine definitely appears to make JavaScript run a whole lot faster than other browsers (even better than Opera in my tests). This video explains a little more on its architecture and working:
V8: an open source JavaScript engine

Having worked on synchronizing various user settings and files from within the major browsers (namely IE, FF, Safari, Opera and Konqueror), it was only natural I started breaking down Chrome and its settings. The first thing I've looked into is finding a way to synchronize its bookmarks. As of this writing, Chrome currently is built for only Windows XP and Windows Vista, with versions for Mac and Linux expected sometime in the near future. Chrome uses SqlLite databases to save all of the settings and preferences. The following blog entry provided some great insights into how the bookmarks are stored in these files:
Greg Duncan's blog

Enriched with the information from the link above, I found writing a java program to extract the bookmarks really simple. With the inclusion of the SQLLite Java wrapper and the corresponding JDBC driver binary, reading from the tables turned out to be a snap. The program was compiled in Netbeans 6.1 with Java 1.6 on a Windows Vista Home Basic edition.

You can download the entire netbeans project from the following link:
ChromeBookmarks.rar

Please feel free to use this code in any way you would like. Just don't point my way if anything crashes ;-)

Cheers.