Electrolysis/BrowserBinding

From MozillaWiki
Jump to: navigation, search

XUL applications use the <browser> to create a browse-able web content widget. The <browser> XBL binding exposes many useful properties.

Background

In the world of Electrolysis, a browser enables out-of-process web content using the remote attribute:

<browser remote="true" ... />

Out-of-process web content breaks many of the XBL properties. The DocShell is not valid so many of the core properties fail: webNavigation, webProgress, contentWindow & contentDocument. These properties make up the foundation of many other properties as well.

Objective

We can create an IPC-aware XBL binding, which extends the current <browser> binding. The goal would be to override as many properties as possible, so the properties either work - or throw errors. We should not silently fail or cause errors far from the root cause.

The IPC-aware XBL binding would live in the same XBL file the current non-IPC binding lives. We can use the remote attribute to enable the IPC-aware binding.

The Plan

The IPC-aware binding would use a content process script, loaded in its constructor using messageManager. The content process script would setup some utility code that would send or receive messages from the chrome XBL binding.

Some examples of content script helpers include:

  • WebProgress: Used to send the current URI from LocationChange which the XBL uses to implement currentURI. Also used to update the canGoBack and canGoForward properties.
  • DOMEvents: Used to listen for some DOM events, like DOMTitleChanged, and send a message back to chrome XBL. The XBL then uses the data, setting contentTitle for example, and then also re-dispatches the DOM event into chrome.
  • WebNavigation: Used by the XBL to implement nsIWebNaviagtion-based methods like goBack, goForward, loadURI, reload and stop.

The current work is happening in bug 560827.