Adding Mochitests to a XULRunner Application

Last weekend I decide to add some Mochitest unit testing to XUL Explorer, one of my XULRunner based applications. Luckily, this is something Dave Townsend already did with a different XULRunner application, McCoy. It was pretty easy to use Dave’s McCoy patch as a basis for getting things working in XUL Explorer. I used XULRunner 1.9.0.4 for building XUL Explorer and, amazingly, my unit tests ran on the first try! Here’s the changeset.

Next, I started working on adding the same support to Fennec. I hit a snag because of changes in Mozilla 1.9.1 to support new types of testing. I made a patch (reviewed and waiting to land) that makes things work again. We are hoping that some of the tweaks needed by Dave’s patch can be rolled into the mainline Mochitests system.

Now that I have some experience under my belt, I plan to add some docs no MDC. I also plan to add the necessary code templates to XUL Explorer and FizzyPop application generators, so anyone making a new XUL application automatically get Mochitest support.

Thanks Dave 🙂

XUL Explorer – Updated!

XUL Explorer is a small tool I started a while ago to allow me to quickly create and preview short snippets of XUL. At the same time, I used the process of building XUL Explorer as a use case to help me discover and learn various parts of the Mozilla platform. With the help of some great contributors, it’s been extended beyond simply previewing XUL.

As a tool, XUL Explorer has been serving me well, but I have been wanting to refine it as an application. As I continue to discover how to use the Mozilla platform to it’s fullest, I want to push those concepts back into XUL Explorer. Therefore, I give you XUL Explorer 1.0a1pre, with the following changes:

  • Proper build system – Project is now using the Mozilla build system which makes building on all three platforms a breeze.
  • Auto-update system – The built-in Mozilla auto-update mechanism has been enabled. The application will periodically check for updates on my server and download/apply them as needed.
  • Updated XULRunner – The bundled XULRunner runtime is now based on the 1.9.0.x branch (same as Firefox 3.0.x). Now you can play with the new XUL elements and platform features.
  • Updated DOM Inspector and Venkman – XUL Explorer now bundles the newest versions (from the 1.9.0.x branch) of these extensions. Using the Mozilla build system makes this simple too
  • A couple small bug fixes and UI tweaks

With the build system changes, I can finally start taking localizations in a manageable fashion. If anyone has a translation you’d like me to add, file a bug here.

Install Windows, OS X (Intel) and Linux versions from here.

A big thanks to Dave Townsend and Matt Gertner for providing some great samples and documentation. Also, the work I have been doing on Prism and Fennec has been helping me expand my knowledge of the Mozilla platform too.

Mozilla Platform, Wizards and FizzyPop

Building things with the Mozilla Platform usually involves dealing with some boilerplate. Extensions have install and chrome manifests and overlays. XULRunner applications have application and chrome manifests and default preferences. XPCOM, even the simpler JavaScript XPCOM, has modules, factories and categories. It’s more than enough to slow developers down, especially new-to-Mozilla developers.

That’s why I have always been thankful to Ted Mielczarek for his Extension Wizard and JS XPCOM Wizard. Those tools have been helpful to me and countless other Mozilla developers.

Because of their great utility, I started to think that Mozilla should host, develop and extend the tools. Turns out, this pleases Ted 🙂 – Therefore, I’ve put together a plan for FizzyPop, a simple project to develop/extend tools that assist Mozilla developers.

I had done a similar project with XUL Explorer, template-driven wizards to create extensions and xul applications. Turns out the Web has a wider reach than a desktop tool, especially for these types of scaffolding projects. In any case, I am taking the templates I use in XUL Explorer and converting them for use in a PHP web application.

I plan to get an SVN repo, bugzilla support and a Mozilla hosted for the project. We want to turn this into a contributor-base project. I’ll let you know when the prototype is ready to start hacking.

New Datasources for XUL Templating [Part 2]

XUL, the XML-based UI language used in Mozilla products, has supported templating for a while now. Unfortunately, the only datasources you could use to drive the templates were RDF-based datasources. This has been a hurdle for some, including me, to really dive into XUL templates.

Back in July, I posted about support for using XML datasources with XUL templates. Recently, Laurent Jouanneau and Neil Deakin landed support for using SQLite-based (mozStorage) datasources. The SQL templates are a little harder to test/demo than the XML ones, but you can get a demo working fairly easily using XUL Explorer (use 0.8 just to be safe).

Laurent added some test cases to the bug. We can take those, add a manifest file and use them from XUL Explorer. Here is a storage-templates.zip archive of the test cases with a simple manifest added. Steps to get the mozStorage template tests working:

  1. Download and unzip somewhere
  2. Startup XUL Explorer
  3. Open the ‘Options’ dialog/sheet
  4. Use the ‘Manifest’ section to add the path to the unzipped manifest file
  5. Open one of the mozStorage XUL test files
  6. Preview the XUL to see it work

Here’s what a simple example looks like:





    template + storage
    Should display all 11 products
    
        
            
            
            
            
        
        
        
        
    


Here’s what that looks like when previewed in XUL Explorer:
simple-mozstorage-template.png

The “dynamic parameters” demo is sorta neat too. It lets you pass a value in to dynamically effect the template query and rebuilds the XUL. Here’s what it looks like:
dynamic-mozstorage-template.png

XUL Explorer – 0.8 Sneaks Out

Yeah, its been awhile since I released XUL Explorer 0.7 and at the time there was a bad editor bug in Mozilla trunk, so I released using an older version of XULRunner. However, the bug has been fixed, so I made some small tweaks & fixes and will release XUL Explorer 0.8 using a XULRunner 1.9b2 pre-release.

Besides the editor bug fix, I wanted to use XUL Explorer to demo some of the new features that landed, including the cool new XML and SQL based XUL templates.

Download from here.

Update: See this post for XUL templating examples using SQL (mozStorage).

XUL Explorer 0.7

I finally pulled enough pieces together to get the next XUL Explorer release ready. Most of the new features in XUL Explorer 0.7 came from contributors which is cool. New in this version:

  • Application and Extension project wizards have much better error handling and validation. The code was restructured so both wizards share a common base class. Thanks to Matt Crocker for the patch.
  • Users can add external manifest folders to XUL Explorer. This is a great help when previewing a XUL file that references external chrome folders. Previously, an erro message would display (missing DTDs) or the XUL wouldn’t style correctly (missing CSS). Now, users can add the manifest folders to XUL Explorer using the Options dialog and the external manifest files will be included when previewing so everything looks right. Thanks to John Marshall for the patch.

    options-manifest.png

  • Autocomplete history lists were added to the Application and Extension project wizards to make it a bit easier to generate code to a previously used folder location. This feature was more about making autocomplete textboxes work and less about usability.

I had to stick with packaging XULRunner 1.8.1.3 (1.8.1 for Mac) because XULRunner 1.9 has a nasty bug that keeps the caret hidden in the editor window.

Download the latest version from here.

Update: I fixed the broken link to the Mac version on the MDC page.