dilluns, febrer 05, 2007

Hosting XBL files

The following html file tests three possible ways of hosting a remote XBL file for use in content-land:

a) Remote served as application/xml
The original Mihai Paparita's XBL file:
http://persistent.info/files/gmail-filter.xml

b) From localhost:9999 served as application/xml
The same file served from a local server. For this I am using the POW(Plain Old Webserver) extension:
https://addons.mozilla.org/firefox/3002/

This is an http server built right into Mozilla. I did not test a separate local web server.

c) Remote served as text/html
The same file served as html from Googlepages. One can upload any file to Googlepages, but it is not possible to adjust the content type.


I made a test by binding the same XBL file from these different locations to text input fields. The binding itself is done in userCrome.css, or alternatively through stylish:

input.a{
display: none !important;
-moz-binding:url(http://persistent.info/files/gmail-filter.xml#filter)!important;
}

input.b{
display: none !important;
-moz-binding:url(http://localhost:9999/input.xml#filter)!important;
}

input.c{
display: none !important;
-moz-binding:url(http://abstellplatz.googlepages.com/input.xml#filter)!important;
}


Test results:


********************************************************************************
* NOTE: this is a normal case known to work *
********************************************************************************
This is an field.

This is the field.

This is the link to 'a' (persistent.info).

********************************************************************************
* NOTE: This does not seem to work, even with mime type application/xml *
* and javascript enabled in localhost:9999 *
********************************************************************************
This is the field.

This is the link to 'b' (localhost).

********************************************************************************
* NOTE: javascript must be enabled in googlepages.com for XBL to work! *
********************************************************************************
This is the field.

This is the link to 'c' (googlepages.com).


Related links:
Grups Google: netscape.public.mozilla.security
XBL for User Style Sheets
XBL in user stlysheets as a substitute for userscripts (think Greasemonkey)
Fun With XBL and XPConnect - MDC
Overlaying XBL bindings | Songbirdnest.com


Update: Good news: Starting with Firefox 3 you can now add XBL content via 'data: urls

Update 10.09.2008: Vorfreude ist die beste Freude: Actually you cannot add XBL via 'data:' urls, as announced. See the answer by Boris Zbarsky to my question on this particular. However:
  • As a partial palliative, Jason Barnabe came up with extending the chrome protocol to allow for inline XBL in CSS directives.
  • From Mr. Zbarky's answer it follows that the correct thing would be to host the CSS document and the XBL at the same domain. It suffices then to @include the remote CSS sheet from the local userContent.css. I will further develop this idea in a future post.