Building an Extension

  • Revision slug: Talk:Building_an_Extension
  • Revision title: Building an Extension
  • Revision id: 82372
  • Created:
  • Creator: Ivor
  • Is current revision? No
  • Comment /* Maybe add some trouble shooting */

Revision Content

Please use the Extensions forum at MozillaZine for general discussion; only put comments about this particular article on this page.

Maybe add some trouble shooting

It's a great article. In fact, I was able to understand most, if not all of the theory. Only problem is it doesn't work. Though I did some small customizations, I came back later and tried again going 100% to the example. Even using C:/extensions/myExtension/ as the folder. Still ceases to work, even when I check the chrome directory via Firefox. So maybe an idea would be to add some trouble shooting to this article? It would help out the slow learners such as myself. --TDC

It is true. Great explanation. Bad execution :S. --SaberGun 02:40, 10 October 2006 (PDT)

Poor description of the email address

This paragraph:

* sample@foo.net - the ID of the extension. This is some value you come up with to identify your extension inemail address format (note that it should not be your email). Make it unique. You could also use a GUID.  NOTE: This parameter MUST be in the format of an email address, although it does NOT have to be a valid email address.  (something@something.something)

leaves the user thinking why would you ever mention an email address if you are not going to be using one. Surely the intent here is to use an email address where the author can be contacted. If this is not the case an explanation needs to be supplied why you should not use it in this way.

Extension Builder: Support

I think it would be worthwhile to add a section which explains how to do this all with Extension Builder. As it makes editing speedier, and easier.

I'd do it, but I am still learning.. lol. --SaberGun 02:48, 10 October 2006 (PDT)

Downloadable template

Is there a downloadable extension template available? That would really help would-be extension authors... --Maian 03:07, 9 October 2005 (PDT)

There's one from another similar article: http://mozilla.doslash.org/stuff/helloworld.zip --Nickolay 12:15, 9 October 2005 (PDT)

No Hello World! in the status bar?

I followed the directions but the status bar didn't change. I already had a number of extensions installed, and I found the source of the problem. If you have a similar problem, change the id="my-panel" line in status.xul to something else, like id="my-panel123". Then everything should be fine. --Brett

Digital finger print readers extension

I am not a programmer and was wondering if I could rally some support to have an extension written so users can operate digital finger print readers within Firefox? This last convenience is the only thing still keeping me tethered to Explorer. vehlewa1 7:45, 3 December 2005 (EST)

localName

Could someone elaborate a little more on what this means? "window is the localName value of the root element of the XUL document..." Where else, for example, does the corresponding word window also appear? I don't see how it is chosen. --Randomandy 06:00, 2005 October 11 (PDT)

It means the part of the tagname excluding the namespace prefix (if it exists) of the document's root element. So if you have some document that looks like <?xml version="1.0"?><xul:dialog xmlns:xul="(xul namespace)">...</xul:dialog>, dialog would be the localName of the root element. If it were just <dialog>...</dialog>, the localName would still be dialog. At least, that's what I think it's saying. I'm not familiar with XUL. --Maian 06:43, 11 October 2005 (PDT)

Localizability

It's good that this article encourages the use of a locale file, but it doesn't really tell you where to put your locale file or how to write an entry for it in your manifest. Perhaps a snippet like the following under Create a Chrome Manifest?

locale    sample    en-US    chrome/chromeFiles/locale/en-US/

--Ox336699 13:54, 5 November 2005 (PST)

Some problems

I tried this article out with a freshly downloaded 1.5 Firefox, but it didn't work. I don't get any errors in the javascript console window. I poked around on the DOM inspector in chrome://browser/content/browser.xul and found the statusbar element that was supposed to be overridden, but I don't see my sample item in there. If I visit my element (which I named fetch rather than sample) at chrome://fetch/content/fetch.xul, I see the 'hello world' content displayed in the inspector's window. It's almost as if the file I created in my profile's extension directory isn't being slurped up. Is there a way to tell if this happened or not?

{{mediawiki.external('Edit:')}} Ah.. missed one of the 'sample' search & replaces in the chrome.manifest file. I needed to open fetch.xul, but was attempting to open sample.xul instead. Didn't see any warnings or anything, so that's what got me. I'm up and running, now, though.

--jrjbertram, 2:30 pm 4 December 2005

Version

From javascript within the extension, how does one read its version? Using InstallTrigger.getVersion('myExtention@example.com') does not work.

--Kurt, 2005-12-21 23:40:00-05

Callek's change to wording

Callek, this change doesn't make sense to me (you forgot to change some punctuation at least). I like the 'go back' variant more fwiw. --Nickolay 08:41, 11 January 2006 (PST)

Sure, I am by far not the best english writer (even though it is my only language). At the time the way it initially was I liked best, so I changed that back. Now though it appears like the 'go back' variant was more comprehensive. Feel free to revert my change at your whim. --Callek 17:22, 11 January 2006 (PST)

What do I use for context menus?

If I wish to add a context menu item to a scpeific element, how would I go about it? What I want is a simple extension for decoding postdata. You right-click on a submit button and have an option that will show the postdata as it would be submitted i.e. first run the form's onsubmit javascript command then output the data as it would be submitted. Also, I would I go about calling the function and viewing the page items? Coppro 16:57, 25 January 2006 (PST)

Please see Extensions:Community Particular the Mozilla Zine Forums link(s). You will find much more help for what you want than on developer documentation Talk Pages. --Callek 22:03, 25 January 2006 (PST)

Images

Just noticed. The added images are not from the extension that is constructed in this tutorial, but from the mozillazine helloworld. I guess including them on this page is quite confusing. --Nickolay 16:02, 15 February 2006 (PST)

Nickolay, allow me to recommend removal of those Images from this article until they are updated to reflect what is actually in this article. --Callek 17:02, 16 February 2006 (PST)

Until the part the part Tests, this article only explain how to create a basic extension and put a text in the status bar panel, but this image shows hello world in the Tools menu, so the guy who don't get it can think that he has done a mistake because he don't got it. (unsigned, by User:Omnisilver, 21 August 2006)

I've gone ahead and removed the images, they do nothing but cause confusion. --04:11, 25 August 2006 (PDT)


Command line handlers section

I commented out the section about command line handlers for three reasons:

  1. Vast majority of extensions don't use command handlers. Chatzilla is not a typical extension, it's a XUL app with hooks into Firefox UI.
  2. "Building an Extension" is an introductory tutorial aimed at people new to extensions or perhaps to Mozilla platform in general. Since CLHs are not essential to extensions, we don't have to put it on this page.
    There is a doc (sort of) on command line handlers, and it can/should easily be found via categories or search facility. If the topic of CLHs is considered to be important enough to beginner extension authors, we could link to that document.
  3. The section in question doesn't actually explain anything. It tries to cover the component registration code and the command line handlers in four sentences. This is not useful. Simply linking to the document about creating XPCOM components and/or about CLHs would be much more efficient.

--Nickolay 18:04, 10 March 2006 (PST)

Nickolay, I would like some mention of commandline handling, even if just a sentence about if your extension wants to handle commandline params, please read the Chrome:_Command_Line doc. Handling is good for all sorts of extensions; almost any extension that provides a separate window should be encouraged to provide a command-line accessor like <tt>-jsconsole</tt> <tt>-inspector</tt> etc. --bsmedberg 18:02, 14 March 2006 (PST)
Okay, I edited the article. --Nickolay 04:52, 15 March 2006 (PST)

Tweaked the Test Section

I'm new here, but FYI: I added a new clause to the Test section. As written, it was slightly inaccurate (and led to some head-scratching on my part), because it implied you should leave your overlay in place (somewhere other than in your profile folder) and could just point to it. But that's not quite true, AFAICT: you need to adjust the chrome.manifest accordingly, so that it actually points to the overlay, rather than pointing into the chrome directory.

Feel free to override me and rewrite if I'm missing something here, but I figured I should pass on the clarification while I thought of it. -- Mark "Justin" Waks 3:26, 12 April 2006 (EST)

You're confused a bit. It's the <tt>content</tt>, <tt>locale</tt>, and <tt>skin</tt> instructions that point to the physical location of extension files. When you specify an overlay using the <tt>overlay</tt> instruction, you don't mention the physical locations - the <tt>chrome://</tt> part of URI means that Gecko should use the chrome registry to find the specified resource (see Chrome Registration for more information about that).
If you still don't get it, feel free to ask additional questions on mozillazine forums or on IRC, and someone will help you. --Nickolay 14:02, 12 April 2006 (PDT)

Skin

I think this document should explain how several skins can be used within an extension. I personaly don't know how to do it. -- Regis Decamps 15:17, 25 September 2006 (PDT)

There are no built-in ways to do that and it's definitely out of scope of this documents. Ask in a newsgroup (detailed question please!) --Nickolay 06:19, 26 September 2006 (PDT)

Revision Source

<dl><dd> <i>Please use the <a class="external" href="http://forums.mozillazine.org/viewforum.php?f=19">Extensions forum</a> at MozillaZine for general discussion; only put comments about this particular article on this page.</i>
</dd></dl>
<h3 name="Maybe_add_some_trouble_shooting"> Maybe add some trouble shooting </h3>
<p>It's a great article. In fact, I was able to understand most, if not all of the theory. Only problem is it doesn't work. Though I did some small customizations, I came back later and tried again going 100% to the example. Even using C:/extensions/myExtension/ as the folder. Still ceases to work, even when I check the chrome directory via Firefox. So maybe an idea would be to add some trouble shooting to this article? It would help out the slow learners such as myself.
--<a href="User:TDC">TDC</a>
</p><p>It is true. Great explanation. Bad execution :S.
--<a href="User:SaberGun">SaberGun</a> 02:40, 10 October 2006 (PDT)
</p>
<h3 name="Poor_description_of_the_email_address"> Poor description of the email address </h3>
<p>This paragraph:
</p>
<pre class="eval">* <b>sample@foo.net</b> - the ID of the extension. This is some value you come up with to identify your extension inemail address format (note that it should not be <i>your</i> email). Make it unique. You could also use a GUID.  NOTE: This parameter MUST be in the format of an email address, although it does NOT have to be a valid email address.  (something@something.something)
</pre>
<p>leaves the user thinking why would you ever mention an email address if you are not going to be using one. Surely the intent here is to use an email address where the author can be contacted. If this is not the case an explanation needs to be supplied why you should not use it in this way.
</p>
<h3 name="Extension_Builder:_Support"> Extension Builder: Support </h3>
<p>I think it would be worthwhile to add a section which explains how to do this all with Extension Builder. As it makes editing speedier, and easier.
</p><p>I'd do it, but I am still learning.. lol.
--<a href="User:SaberGun">SaberGun</a> 02:48, 10 October 2006 (PDT)
</p>
<h3 name="Downloadable_template"> Downloadable template </h3>
<p>Is there a downloadable extension template available? That would really help would-be extension authors... --<a href="User:Maian">Maian</a> 03:07, 9 October 2005 (PDT)
</p>
<dl><dd>There's one <a class="external" href="http://kb.mozillazine.org/Getting_started_with_extension_development#Resources">from another similar article</a>: http://mozilla.doslash.org/stuff/helloworld.zip --<a href="User:Nickolay">Nickolay</a> 12:15, 9 October 2005 (PDT)
</dd></dl>
<h3 name="No_Hello_World.21_in_the_status_bar.3F"> No Hello World! in the status bar? </h3>
<p>I followed the directions but the status bar didn't change.  I already had a number of extensions installed, and I found the source of the problem.  If you have a similar problem, change the id="my-panel" line in status.xul to something else, like id="my-panel123".  Then everything should be fine.
--<a href="User:Brett73">Brett</a>
</p>
<h3 name="Digital_finger_print_readers_extension"> Digital finger print readers extension </h3>
<p>I am not a programmer and was wondering if I could rally some support to have an extension written so users can operate digital finger print readers within Firefox?  This last convenience is the only thing still keeping me tethered to Explorer.
<a href="User:Vehlewa1">vehlewa1</a> 7:45, 3 December 2005 (EST)
</p>
<h3 name="localName"> localName </h3>
<p>Could someone elaborate a little more on what this means? <i>"window is the localName value of the root element of the XUL document..."</i> Where else, for example, does the corresponding word <i>window</i> also appear? I don't see how it is chosen.
--<a href="User:Randomandy">Randomandy</a> 06:00, 2005 October 11 (PDT)
</p>
<dl><dd> It means the part of the tagname excluding the namespace prefix (if it exists) of the document's root element. So if you have some document that looks like &lt;?xml version="1.0"?&gt;&lt;xul:dialog xmlns:xul="(xul namespace)"&gt;...&lt;/xul:dialog&gt;, dialog would be the localName of the root element. If it were just &lt;dialog&gt;...&lt;/dialog&gt;, the localName would still be dialog. At least, that's what I think it's saying. I'm not familiar with XUL. --<a href="User:Maian">Maian</a> 06:43, 11 October 2005 (PDT)
</dd></dl>
<h3 name="Localizability"> Localizability </h3>
<p>It's good that this article encourages the use of a locale file, but it doesn't really tell you where to put your locale file or how to write an entry for it in your manifest.  Perhaps a snippet like the following under <i>Create a Chrome Manifest</i>?
</p>
<pre class="eval">locale    sample    en-US    chrome/chromeFiles/locale/en-US/
</pre>
<p>--<a href="User:Ox336699">Ox336699</a> 13:54, 5 November 2005 (PST)
</p>
<h3 name="Some_problems"> Some problems </h3>
<p>I tried this article out with a freshly downloaded 1.5 Firefox, but it didn't work.  I don't get any errors in the javascript console window.  I poked around on the DOM inspector in chrome://browser/content/browser.xul and found the statusbar element that was supposed to be overridden, but I don't see my sample item in there.  If I visit my element (which I named fetch rather than sample) at chrome://fetch/content/fetch.xul, I see the 'hello world' content displayed in the inspector's window.  It's almost as if the file I created in my profile's extension directory isn't being slurped up.  Is there a way to tell if this happened or not?
</p><p>{{mediawiki.external('Edit:')}} Ah.. missed one of the 'sample' search &amp; replaces in the chrome.manifest file.  I needed to open fetch.xul, but was attempting to open sample.xul instead.  Didn't see any warnings or anything, so that's what got me.  I'm up and running, now, though.
</p><p>--jrjbertram, 2:30 pm 4 December 2005
</p>
<h3 name="Version"> Version </h3>
<p>From javascript within the extension, how does one read its version?
Using InstallTrigger.getVersion('myExtention@example.com') does not work.
</p><p>--<a href="User:Kurtb149">Kurt</a>, 2005-12-21 23:40:00-05
</p>
<h3 name="Callek.27s_change_to_wording"> Callek's change to wording </h3>
<p>Callek, <a class="external" href="http://developer.mozilla.org/en/docs/index.php?title=Building_an_Extension&amp;curid=3657&amp;diff=23564&amp;oldid=23549&amp;rcid=23601">this change</a> doesn't make sense to me (you forgot to change some punctuation at least). I like the 'go back' variant more fwiw. --<a href="User:Nickolay">Nickolay</a> 08:41, 11 January 2006 (PST)
</p>
<dl><dd> Sure, I am by far not the best english writer (even though it is my only language).  At the time the way it initially was I liked best, so I changed that back. Now though it appears like the 'go back' variant was more comprehensive.  Feel free to revert my change at your whim. --<a href="User:Callek">Callek</a> 17:22, 11 January 2006 (PST)
</dd></dl>
<h3 name="What_do_I_use_for_context_menus.3F"> What do I use for context menus? </h3>
<p>If I wish to add a context menu item to a scpeific element, how would I go about it? What I want is a simple extension for decoding postdata. You right-click on a submit button and have an  option that will show the postdata as it would be submitted i.e. first run the form's onsubmit javascript command then output the data as it would be submitted. Also, I would I go about calling the function and viewing the page items? <a href="User:Coppro">Coppro</a> 16:57, 25 January 2006 (PST)
</p>
<dl><dd> Please see <a href="en/Extensions/Community">Extensions:Community</a> Particular the Mozilla Zine Forums link(s).  You will find much more help for what you want than on developer documentation Talk Pages. --<a href="User:Callek">Callek</a> 22:03, 25 January 2006 (PST)
</dd></dl>
<h3 name="Images"> Images </h3>
<p>Just noticed. The added images are not from the extension that is constructed in this tutorial, but from the mozillazine helloworld. I guess including them on this page is quite confusing. --<a href="User:Nickolay">Nickolay</a> 16:02, 15 February 2006 (PST)
</p>
<dl><dd>Nickolay, allow me to recommend removal of those Images from this article until they are updated to reflect what is actually <b>in</b> this article. --<a href="User:Callek">Callek</a> 17:02, 16 February 2006 (PST)
</dd></dl>
<p>Until the part the part <a class="external" href="http://developer.mozilla.org/en/docs/Building_an_Extension#Test">Tests</a>, this article only explain how to create a basic extension and put a text in the status bar panel, but <a class="external" href="http://developer.mozilla.org/wiki-images/en/4/42/Helloworld_tools_menu.PNG">this image</a> shows <i>hello world</i> in the Tools menu, so the guy who don't get it can think that he has done a mistake because he don't got it. (unsigned, by <a href="User:Omnisilver">User:Omnisilver</a>, 21 August 2006)
</p>
<dl><dd>I've gone ahead and removed the images, they do nothing but cause confusion. --04:11, 25 August 2006 (PDT)
</dd></dl>
<p><br>
</p>
<h3 name="Command_line_handlers_section"> Command line handlers section </h3>
<p>I commented out the section about command line handlers for three reasons:
</p>
<ol><li> Vast majority of extensions don't use command handlers. Chatzilla is not a typical extension, it's a XUL app with hooks into Firefox UI.
</li><li> "Building an Extension" is an introductory tutorial aimed at people new to extensions or perhaps to Mozilla platform in general. Since CLHs are not essential to extensions, we don't have to put it on this page.<br> There is a doc (sort of) on command line handlers, and it can/should easily be found via categories or search facility. If the topic of CLHs is considered to be important enough to beginner extension authors, we could link to that document.
</li><li> The section in question doesn't actually explain anything. It tries to cover the component registration code and the command line handlers in <i>four</i> sentences. This is not useful. Simply linking to the document about creating XPCOM components and/or about CLHs would be much more efficient.
</li></ol>
<p>--<a href="User:Nickolay">Nickolay</a> 18:04, 10 March 2006 (PST)
</p>
<dl><dd>Nickolay, I would like some mention of commandline handling, even if just a sentence about if your extension wants to handle commandline params, please read the Chrome:_Command_Line doc. Handling is good for all sorts of extensions; almost any extension that provides a separate window should be encouraged to provide a command-line accessor like <tt>-jsconsole</tt> <tt>-inspector</tt> etc. --<a href="User:Benjamin_Smedberg">bsmedberg</a> 18:02, 14 March 2006 (PST)
</dd></dl>
<dl><dd><dl><dd> Okay, I edited the article. --<a href="User:Nickolay">Nickolay</a> 04:52, 15 March 2006 (PST)
</dd></dl>
</dd></dl>
<h3 name="Tweaked_the_Test_Section"> Tweaked the Test Section </h3>
<p>I'm new here, but FYI: I added a new clause to the Test section. As written, it was slightly inaccurate (and led to some head-scratching on my part), because it implied you should leave your overlay in place (somewhere other than in your profile folder) and could just point to it. But that's not quite true, AFAICT: you need to adjust the chrome.manifest accordingly, so that it actually points to the overlay, rather than pointing into the chrome directory.
</p><p>Feel free to override me and rewrite if I'm missing something here, but I figured I should pass on the clarification while I thought of it. -- <a href="User:Jducoeur">Mark "Justin" Waks</a> 3:26, 12 April 2006 (EST)
</p>
<dl><dd> You're confused a bit. It's the <tt>content</tt>, <tt>locale</tt>, and <tt>skin</tt> instructions that point to the physical location of extension files. When you specify an overlay using the <tt>overlay</tt> instruction, you don't mention the physical locations - the <tt>chrome://</tt> part of URI means that Gecko should use the chrome registry to find the specified resource (see <a href="en/Chrome_Registration">Chrome Registration</a> for more information about that).<br> If you still don't get it, feel free to ask additional questions on mozillazine forums or on IRC, and someone will help you. --<a href="User:Nickolay">Nickolay</a> 14:02, 12 April 2006 (PDT)
</dd></dl>
<h3 name="Skin"> Skin </h3>
<p>I think this document should explain how several skins can be used within an extension. I personaly don't know how to do it. -- <a href="User:Regis_Decamps">Regis Decamps</a> 15:17, 25 September 2006 (PDT)
</p>
<dl><dd> There are no built-in ways to do that and it's definitely out of scope of this documents. Ask in a newsgroup (detailed question please!) --<a href="User:Nickolay">Nickolay</a> 06:19, 26 September 2006 (PDT)
</dd></dl>
Revert to this revision