1

On MDN, the phrase "Add-on Manager-enabled XUL application" is introduced.

By dragging a XPI file containing an add-on and dropping it onto a FireFox window, the addon's widgets will be installed in FireFox's add-on bar.

I can also use Firefox to run a XUL application by specifying the commandline option "-app application.ini".

Since MDN makes me think that the two are not mutually exclusive, I'm looking for a simple 4 step process where steps 1 and 2 are create a XUL application and XPI independently, step 3 describes how to change either the XUL application or the XPI in preparation for step 4, and step 4 is final integration.

I'll start you off with steps 1 and 2, and then suggest some things that need to be done in steps 3 or 4.

Step 1: Build the XPI by following the tutorial at https://addons.mozilla.org/en-US/developers/docs/sdk/1.3/dev-guide/addon-development/implementing-simple-addon.html

Step 2: Build the XUL application by following the tutorial at https://developer.mozilla.org/en/Getting_started_with_XULRunner

Now for Steps 3 and 4. They should include modifying the application.ini built in step 2 by adding the code:

[XRE]
EnableExtensionManager=1

They should also include adding lines to prefs.js to support the extension manager. And they may require adding addon bar window element to XUL by adding code similar to:

<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton 
    id="xfox-statusbarpanel" class="toolbarbutton-1 chromeclass-toolbar-additional"
    label="&name;"
    tooltiptext="&name;"
    oncommand="toggleSidebar('xfox-sidebar');"
    context="xfox-contextmenu">
</toolbarbutton>
</toolbarpalette>

I've succeeded in making the "Add-on Manager-enabled XUL application" (aka <TestApp>) accept the XPI (aka <wikipanel>) and attempt to install it, but it fails with the error message: "<wikipanel> could not be installed because it is not compatible with <TestApp version 1.0>"

[edit] I editted INSTALL.RDF (for my XPI) and added the following:

<em:targetApplication>
   <Description>
     <em:id>testapp@sample.xul</em:id>
     <em:minVers‌​ion>0.0</em:minVersion>
     <em:maxVersion>9.*</em:maxVersion>
   </Description>
 </em:targe‌​tApplication>.

The extension now installs, but I am getting the following error in jsconsole:

Error: The widget module currently supports only Firefox. In the future it will support other applications. Please see https://bugzilla.mozilla.org/show_bug.cgi?id=560716 for more information.

Nickolay
  • 31,095
  • 13
  • 107
  • 185
vo1stv
  • 55
  • 2
  • 17
  • [how-to-inspect-my-standalone-xul-app-using-dom-inspector-or-similar](http://stackoverflow.com/questions/4648365/how-to-inspect-my-standalone-xul-app-using-dom-inspector-or-similar) – vo1stv Dec 01 '11 at 04:43
  • The phrase "addon's widgets" sounds like you are using the [Add-on SDK](https://addons.mozilla.org/en-US/developers/docs/sdk/1.3/packages/addon-kit/docs/widget.html). Do you? Or is it a "classic" extension? – Wladimir Palant Dec 01 '11 at 06:00
  • @WladimirPalant Yes I am using JetPack for the XPI addon. I've read http://stackoverflow.com/questions/7670282/using-jetpack-to-add-toolbar-buttons-integrating-xul-and-jetpack-for-firefox-ad and it appears XUL used to be supported by the -t flag (has this been changed to the --templatedir flag in newer version?). I'm looking for a simple 4 step answer where steps 1 and 2 are create XUL and XPI independently, and steps 3 and 4 describe the changes necessary to integrate the two. – vo1stv Dec 03 '11 at 14:08
  • (P.S. I am using the addon-sdk-1.3 version of the Add-on SDK. I incorrectly referred to it as JetPack - though I vote to bring back the JetPack name, it's catchy) – vo1stv Dec 03 '11 at 14:40
  • "Add-on Manager-enabled XUL **application**" on that page refers to Firefox, Thunderbird and others. – Nickolay Dec 04 '11 at 13:40
  • @Nickolay: Thanks to the insight regarding applications, I editted INSTALL.RDF (for my XPI) and added the following: ``testapp@sample.xul0.09.*``. The extension now installs, but I am getting the following error in jsconsole: ``Error: The widget module currently supports only Firefox. In the future it will support other applications. Please see https://bugzilla.mozilla.org/show_bug.cgi?id=560716 for more information.`` – vo1stv Dec 06 '11 at 18:57
  • @SmileAndNod: I edited your question so that it makes sense, based on your clarifications in the comments. Is my edit correct? – Nickolay Dec 07 '11 at 01:37
  • It's suitable. (another 1730 reputation points to go before I earn that privilege :-) ) – vo1stv Dec 07 '11 at 04:58

2 Answers2

1

You are mixing things up here. The -app command line flag is there to run XULRunner applications, not browser extensions. As to Add-on SDK, it doesn't have XUL support, only HTML. There is a fork of the Add-on SDK with XUL support but it looks somewhat outdated and I'm not sure whether it is capable of creating standalone windows (is that what you are asking about?).

There are of course classic extensions. They allow you to do anything including creating new XUL windows or using the add-on bar. But they are quite a bit more complicated to write.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
  • Thanks for clarifying the terms extensions versus applications. When I first learned XUL, I referred to Moziila's ["Building an Extension"](https://developer.mozilla.org/en/Building_an_Extension), so that is the source of my confusion. I guess "applications" and "classic extensions" are very similar. Regardless, whereever XUL is mentioned above, it is with respect to a (chrome) application. Whereever XPI is mentioned, it is with respect to something (addon,plugin?) built via ``cfx xpi`` from the [Add-on SDK](https://addons.mozilla.org/en-US/developers/docs/sdk/1.3/dev-guide/welcome.html) – vo1stv Dec 05 '11 at 12:42
1

I've found the answer but it is a bit of a hack and requires removing the following lines of code from the addon-kit javascript source:

if (!require("api-utils/xul-app").is("Firefox")) {
    throw new Error([
      "The widget module currently supports only Firefox.  In the future ",
      "it will support other applications. Please see ",
      "https://bugzilla.mozilla.org/show_bug.cgi?id=560716 for more information."
    ].join(""));
}

Since the above code is specifically designed to prevent using the addon kit in anything other than bonafide Firefox, this avenue is not worth pursuing further. However, if there is a way to build a xul-app in such a way that it conforms to Firefox, then I will revisit the issue.

Firefox is chrome://browser/content/browser.xul after all.

vo1stv
  • 55
  • 2
  • 17