Pergunta

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.

Foi útil?

Solução 2

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.

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top