Mozilla logo
slanted Mozilla logo
Cover page images

Mozilla development
there is no data, there is only xul

Fabien Cazenave <kaze@kompozer.net>

Update by Laurent Jouanneau <laurent@xulfr.org>

XUL Overview

Developer Profile

Developer Profile

Developer Preferences (about:config)

Add these prefs with about:config:

Developer Preferences (prefs.js)

Alternative: add these lines to %profile%/prefs.js

      user_pref("browser.dom.window.dump.enabled",     true);
      user_pref("extensions.logging.enabled",          true);
      user_pref("javascript.options.strict",           true);
      user_pref("javascript.options.showInConsole",    true);
      user_pref("nglayout.debug.disable_xul_cache",    true);
      user_pref("nglayout.debug.disable_xul_fastload", true);

warning: don't touch %profile%/prefs.js while Firefox is running!

More details on MDN: Setting up an extension development environment.

Questions?

Chrome URLs

Chrome Manifests

Chrome Packages

XPI Extension Structure

example:

exampleExt.xpi:
    chrome/
        content/
        locales/
        skin/
    components/
        components/cmdline.js
    modules/
         myJSmodule.js
    defaults/
        preferences/*.js
    chrome.manifest
    install.rdf

install.rdf

install.rdf stores the extension’s metadata:

<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  <Description about="urn:mozilla:install-manifest">
    <em:id>inspector@mozilla.org</em:id>
    <em:version>2.0.4</em:version>

    <em:targetApplication>
      <!-- Firefox -->
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
        <em:minVersion>3.0a1</em:minVersion>
        <em:maxVersion>3.7a1pre</em:maxVersion>
      </Description>
    </em:targetApplication>

    <em:targetApplication>
      <!-- Thunderbird -->
      <Description>
        <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
        <em:minVersion>3.0a1pre</em:minVersion>
        <em:maxVersion>3.1a1pre</em:maxVersion>
      </Description>
    </em:targetApplication>

    <!-- front-end metadata -->
    <em:name>DOM Inspector</em:name>
    <em:description>Inspects the structure and properties of a window and its
    contents.</em:description>
    <em:creator>mozilla.org</em:creator>
    <em:homepageURL>http://www.mozilla.org/projects/inspector/</em:homepageURL>

  </Description>
</RDF>

Bootstrapped extensions

XULRunner Applications

application.ini

[App]
Vendor=MIAGE Evry
Name=CoMETE
Version=0.1
BuildID=20101207
Copyright=Copyleft MIAGE Evry
ID=comete@mozilla.org

[Gecko]
MinVersion=1.8
MaxVersion=2.0.*

[XRE]
EnableExtensionManager=1
EnableProfileMigrator=0 

Chrome “Proxy”

Now let’s “proxy” this archive to get a chrome URL:

Congrats: you’ve just turned a XUL page into an extension! :-)

Questions?

XUL Overlays

Overlays are XUL files used to describe extra content in the UI.

Overlays on Firefox

when designing an extension, there are three main places where you’d be likely to add a button:

Use DOM Inspector to inspect the browser UI:

chrome://browser/content/

and find where you can attach overlays.

Placing Overlaid Elements

By default, overlaid elements are put at the end of the parent container.
These three attributes can help:

Note #1: the values of insertbefore and insertafter can be comma-separated lists
⇒ the first matching id in the list is used to determine the position.

Note #2: overlays can also be used to remove elements
e.g. to remove the “about” menu entry:

<menupopup id="help-popup">
  <menuitem removeelement="true" id="help-about">
</menupopup> 

Using Overlays

3 main reasons to use an overlay:

3 ways to load an overlay:

Questions?

Keyboard shortcuts

Windows

Dialog

Let’s see! :-)

to fire the table.xul window, add:

…and register the overlay properly.

Bonuses: