Archive for November, 2008

Introducing the Browser D-Bus Bridge

Monday, November 3rd, 2008

The Browser D-Bus Bridge is a way to use D-Bus services with JavaScript from a browser application.

Just to be clear (this is a very common concern), it does *not* mean using D-Bus from web sites. The target audience for the Bridge is browser extension and UI developers, not web developers. Using web technologies (HTML, CSS, JavaScript…) to build applications is an increasingly interesting thing, and this is another step in that direction. Currently the Bridge only has API for clients, so you can’t (easily) implement a D-Bus service with it (yet).

The way we have approached this is to create a thin API to bind the basic functionality of D-Bus into JavaScript. This is to minimize the work needed in the actual browser-to-D-Bus bridging. This low-level API can then be used to wrap D-Bus services with JavaScript to give a comfortable end-user API.

There are two implementations of the Browser D-Bus Bridge, one for use in Gecko-based applications and one for WebKit-based applications. We have tried to use the most natural way for of integrating with the engine for both cases. For Gecko this means creating an XPCOM service and for WebKit an add-on library.

Currently the Bridge is lacking support for some of the more complex types and deeply nested message signatures, but it’s already usable for example controlling NetworkManager or querying HAL for the battery level. Future plans for the Bridge include (naturally) finishing the message args support, adding introspection support (this might be implemented just in the JavaScript side though) and later adding API for implementing services from JavaScript.

Good starting points for the Bridge are the wiki page and browsing the source code.

We don’t have a bugzilla or mailing list for the Bridge, but you can mail me at kalle.vahlman at and I’ll try to help in any way I can. Oh, and I’ll gladly integrate patches too ;)