In the past several days I tried out Google‘s latest browser, Google Chrome 8.
Indeed it is very fast when coming to HTML rendering and JS execution, but its non-uniform look with the system and the lack of extension support, makes it very frustrating for me to use it.
Unlike Firefox and other Mozilla platform based browsers, in which extensions can have full access to the browser itself and content document, Chrome extensions are divided into two parts:
- Background pages
- Content scripts
Each of them are restricted either to the browser chrome, or the content document. And they communicate through message passing. It can be illustrated as so (excuse me for my Inkscape skills):

Compared to Firefox, it is quite convenient to develop a light weight extension to Chrome: it’s just like using Greasemonkey with user scripts. However, the defects of the underlying JavaScript language, makes it very hard, if not impossible, to develop a large-scale extension.
The message passing between content scripts and background is surely asynchronous, while due to the implementation of underlying JavaScript language, it’s essentially impossible to block on an asynchronous call, as JavaScript is executed in one thread. You need to provide a callback. Combined with the native infectiousness of asynchronous calls, if you use it in a part of your code, it’s likely to spread over all your code.
Consider this situation: an extension’s preferences is stored in the localStorage provided by the browser. In order to access it’s very own preference, a content script need to make an asynchronous call to the background script. And…? You see here that we now need to arrange our code in favour of where the asynchronous calls appear, instead of their functionalities.
Yes, this is an issue for all JavaScript asynchronous calls, but in Chrome, the separation of content and browser, forces away all other work-arounds: the only thing you can pass as a message, must be a JSON object.
Furthermore, there are some other needless restrictions for content scripts: their XMLHttpRequests must obey the same origin policy. But, the background script are not restricted by this, and could therefore pass the result of XHR to content scripts by message passing mentioned above. So, what’s the use for restricting these content scripts? This completely makes no sense.
The tolerance of JavaScript has already introduced so much amateur, error-prone code, and the extension framework of Google Chrome even make well structured programs impossible to write.