Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

minimum chrome.manifest and install.rdf

126 views
Skip to first unread message

bootstrap

unread,
Mar 21, 2012, 7:23:57 PM3/21/12
to
I am trying to make an extension that is one javascript file.
What is the minimum acceptable information to put inside
the chrome.manifest and install.rdf files in this case, and
where do these files belong in the ubuntu64 filesystem so
firefox installs the extension (at least during development)?

Note: My extension has:
- no menus
- no buttons
- no GUI elements
- no new menu elements
- nothing visible in the chrome
- no text (so no strings, so no locale is relevant)

So, can my extension only contain those two basic files
plus my javascript program (to execute in the chrome)?
What does the line of text look like in chrome.manifest
that references my javascript file? Or do I need to create
the many subdirectories and files shown in MDN webpages
and leave those files empty... or something?

Jorge Villalobos

unread,
Mar 22, 2012, 10:33:54 AM3/22/12
to bootstrap
One way to create a really minimalist extension is to create a
boostrapped one:

https://developer.mozilla.org/en/Extensions/Bootstrapped_extensions

With this you only need and install.rdf and your script. If you use a
traditional extension then you need a chrome manifest with an overlay
entry, a XUL overlay file and either a separate script file or all of
your script code in the XUL file.

As for the minimal install manifest, the required fields are specified here:

https://developer.mozilla.org/en/install_manifests

- Jorge

bootstrap

unread,
Mar 23, 2012, 4:00:09 AM3/23/12
to
> - Jorge- Hide quoted text -
>
> - Show quoted text -

Thanks for the tips. A few followup questions that I must
have missed the answers to (or I'm just not 100% clear):

#1: I made the install.rdf file per instructions. However
nothing in the description says anything about putting the
name or path to my javascript file inside the install.rdf file.
How does this work? Does the [bootstrap] extension
mechanism find the javascript file inside the XPI file and
assume "this must be the extension"? If not, then how?

#2: How does firefox know which extensions to load
when it starts up? In other words, how do I get firefox
to load my extension? Does firefox look in some path
for all files with a .xpi extent and assume they should
be loaded and executed? I searched my entire filesystem
for .xpi files and there were only these two:
/usr/lib/firefox-addons/extensions/langpack-en-
G...@firefox.mozilla.org.xpi
/usr/lib/firefox-addons/extensions/langpack-en-
Z...@firefox.mozilla.org.xpi

#3: Must I create a new XPI file for every iteration of
development / testing / debugging of the javascript in
my extension? One of the webpages you pointed me
at says yes. That is a pretty large, annoying hassle if
that's true. What's the deal? I created a firefox "dev"
profile for developing my extension on firefox in case
that makes any difference.

#4: Does my javascript have the same priveledges
as javascript "running in the chrome"? I ask that
because somewhere I read that javascript trying to
execute window.open() requires user approval every
time window.open() is called - unless the javascript
is "running in the chrome".

Jonathan Protzenko

unread,
Mar 23, 2012, 4:12:28 AM3/23/12
to bootstrap, dev-ext...@lists.mozilla.org
I think the page you're looking for is
https://developer.mozilla.org/en/Setting_up_extension_development_environment

Cheers,

jonathan
> _______________________________________________
> dev-extensions mailing list
> dev-ext...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-extensions

bootstrap

unread,
Mar 23, 2012, 10:50:19 AM3/23/12
to
On Mar 23, 1:12 am, Jonathan Protzenko <jonathan.protze...@gmail.com>
wrote:
> I think the page you're looking for is https://developer.mozilla.org/en/Setting_up_extension_development_env...
>
> Cheers,
> jonathan

Thanks for that link. It was helpful (got one to work), but further
research of bootstrap extensions indicates they can't do some
things my extension needs to.

bootstrap

unread,
Mar 23, 2012, 10:59:24 AM3/23/12
to

An update. I managed to create a minimalist extension
with just these two files:

chrome.manifest
install.rdf

It doesn't do anything, but at least when I look at the
content of the Tools => WebDeveloper => ErrorConsole
the indication is the extension loads okay. And when
I look in Tools => Addons => Extensions it lists my
extension as installed.

HOWEVER, it is not loading or executing my javascript file,
and I can't figure out how to make it do so. I tried putting a
reference in chrome.manifest to a contents/meanings.xul file,
then in the meanings.xul file tried to overlay the browser with
the javascript program (instead of another xul file), but that
didn't work.

I don't need to add or change any UI elements of the browser,
or all anything to menus, or so forth. I do need my javascript
to have access to HTML documents after they load to capture
mousemove events, inspect the document hierarchy, etc.

How do I tell my extension to load and run my javascript file?

Gijs Kruitbosch

unread,
Mar 23, 2012, 11:14:41 AM3/23/12
to
So you need to run JS in every browser window. To do that with this approach,
you'll need to add a <script> tag to each opening browser window, and make sure
to remove (the effects of) your script when the add-on unloads.

Here's how to listen for new browser windows being created:
http://www.oxymoronical.com/blog/2011/01/Playing-with-windows-in-restartless-bootstrapped-extensions

(also note the comments)

Adding a script tag is done using 'normal' DOM manipulation. The browser window
has a document, which has a documentElement, to which you can append a new tag
created in that document.

In any case, it actually sounds like you'd be better off building an add-on with
the add-on builder, even if that'll probably leave you with more than just those
three files:

https://addons.mozilla.org/en-US/developers/builder

Cheers,
Gijs

bootstrap

unread,
Mar 23, 2012, 9:44:10 PM3/23/12
to
On Mar 23, 8:14 am, Gijs Kruitbosch <gijskruitbo...@gmail.com> wrote:
> On 23/03/2012 15:59 PM, bootstrap wrote:
>> An update.  I managed to create a minimalist but regular
>> (NOT bootstrapped) extension with just these two files:
>>
>>   chrome.manifest
>>   install.rdf
>>
>>   It doesn't do anything, but at least when I look at the
>>   content of the Tools =>  WebDeveloper =>  ErrorConsole
>>   the indication is the extension loads okay.  And when
>>   I look in Tools =>  Addons =>  Extensions it lists my
>>   extension as installed.
>>
>>   HOWEVER, it is not loading or executing my javascript file,
>>   and I can't figure out how to make it do so.  I tried putting a
>>   reference in chrome.manifest to a contents/meanings.xul file,
>>   then in the meanings.xul file tried to overlay the browser with
>>   the javascript program (instead of another xul file), but that
>>   didn't work.
>>
>>   I don't need to add or change any UI elements of the browser,
>>   or all anything to menus, or so forth.  I do need my javascript
>>   to have access to HTML documents after they load to capture
>>   mousemove events, inspect the document hierarchy, etc.
>>
>>   How do I tell my extension to load and run my javascript file?
>
>
> So you need to run JS in every browser window. To do that with
> this approach, you'll need to add a <script> tag to each opening
> browser window, and make sure to remove (the effects of) your
> script when the add-on unloads.
>
> Here's how to listen for new browser windows being created:
> http://www.oxymoronical.com/blog/2011/01/Playing-with-windows-in-rest...
>
> (also note the comments)
>
> Adding a script tag is done using 'normal' DOM manipulation.
> The browser window has a document, which has a
> documentElement, to which you can append a new tag
> created in that document.
>
> In any case, it actually sounds like you'd be better off building an
> add-on with the add-on builder, even if that'll probably leave you
> with more than just those three files:
>
> https://addons.mozilla.org/en-US/developers/builder
>
> Cheers,
> Gijs- Hide quoted text -
>
> - Show quoted text -

Just to be clear. The do-nothing extension that
works is a regular extension, not bootstrapped.

First to answer your question: Yes, I need my
extension to function in every browser window
that opens up, whether that browser window
opens because the user clicks on the firefox
icon on his desktop, or because the javascript
in my extension creates another window with
the window.open() function.

I am so confused. I thought regular extensions
automatically have access to the contents of the
DOM for every frame and window ever created
without having to jump through hoops like what
is described in your "oxymoronical" link. In fact,
that article appears to confirm that impression,
though there is still the question of whether a
regular extension MUST HAVE an actual overlay
for the javascript to exist/work/see-window-objects.

So I need to ask whether your suggestion applies
to a regular extension too, or only bootstrapped?
Because I must create a regular extension since
some of the capabilities I need are not available
to bootstrap extensions.

Can you clear this up for me? And if you know,
can the javacript code in my regular extension
execute even though I don't need to add or change
any browser UI elements? And do I have to perform
an "overlay" in order to get the javascript to run?
And if so, what do I "overlay" if I don't want to
change anything in the browser UI? I suppose
I could add something pointless to the UI if that
is necessary to make my javascript run - as long
as the javascript has access to all windows created
in all browser windows.

Oh, and what IS an "overlay", exactly?

Jonathan Protzenko

unread,
Mar 24, 2012, 6:20:59 AM3/24/12
to bootstrap, dev-ext...@lists.mozilla.org
https://developer.mozilla.org/en/Building_an_Extension will help you
get the basics and figure out how to get an overlay working.

An overlay basically says "hey, whenever you see that window, just add
that piece of interface to it". That allows you to say "hey, whenever
you see a browser window, please add a <script
src='my-fancy-script.js'> element". This means everytime a browser
window is loaded, you can ask for your script to be loaded as well. You
script will then be able to poke at the browser window, watch for new
tabs being opened, etc. etc.

jonathan

bootstrap

unread,
Mar 25, 2012, 2:43:35 AM3/25/12
to
On Mar 24, 3:20 am, Jonathan Protzenko <jonathan.protze...@gmail.com>
wrote:
> https://developer.mozilla.org/en/Building_an_Extensionwill help you
> > dev-extensi...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-extensions- Hide quoted text -
>
> - Show quoted text -

Okay. I guess the lack of an specific answer from
anyone means my extension must create a useless
UI element in order to be able to execute javascript.
I was hoping that wasn't necessary, but my every
attempt so far has failed.

Jonathan Protzenko

unread,
Mar 25, 2012, 5:10:38 AM3/25/12
to bootstrap, dev-ext...@lists.mozilla.org
I don't know how I can provide a clearer answer:
- either you do a restartless addon, and you use a technique such as
https://github.com/protz/GMail-Conversation-View/blob/master/bootstrap.js#L143
to watch for new windows being opened and add your code into each one
of them,
- or you use the overlay mechanism to specify *which* window your
<script> element should be added to.

A <script> element isn't a useless UI element, it is the regular way to
make your code run in a given window.

Cheers,

jonathan

bootstrap

unread,
Mar 26, 2012, 8:28:09 AM3/26/12
to
Well, maybe I'm just dense. I've read endless webpages
about extensions, and they all show these .xul files that
create UI elements that overlay the browser UI elements
and SOMETIMES also mention an overlayname.js file to
execute javascript. However, whenever I try this syntax
or that syntax (every alternative that I can think of) that
names the overlayname.js file but NOT any corresponding
UI element... either the browser pukes (spews a bunch of
errors to the error console), or nothing happens at all.

Unfortunately, a bootstrapped extension is insufficient
for my purposes according to every article I've read.
That did seem to be promising, but my extension
must create and interact with additional windows
that hide/show under javascript programmatic control
without getting permission from the user every time.
And there were other limitations of bootstrapped that
also made them unacceptable, unfortunately.

I'm not quite sure what this "watch for windows being
opened" technique is, unless it is something extremely
complex and limited that was talked about in one of
the articles about bootstrapped extensions.

Here is the bottom line. My extension needs to work
on EVERY window that displays HTML. This includes
every window my extension creates to perform the
services it provides. In other words, when my extension
calls window.open() to create new windows to display
information for the user, the services of my extension
need to work on those windows too.

I ***know*** the <script> element isn't a useless UI element!
But so far I have not been able to make extension process
accept my "script" (javascript) unless the javascript file is
registered as part of some other visible XUL UI element like
a new menu-item or something. I mean, have YOU tried to
create a regular extension that has an overlay that ONLY
names a javascript file without any other XUL or UI element
of any kind involved? If so, then I'm simply too stupid to
guess the correct syntax for that from all the simple
extension examples I've been working with. It is quite
possible I'm just being stupid and not seeing the implicit
"sense" of the overlay syntax. I'm not seeing the sense,
which makes it appear to me that an overlay cannot exist
that is simply a javascript filename without any other
XUL UI element at all.

Here is one additional worry I have, that supposedly is
not a problem (according to one javascript book I have).
My extension needs to create two kinds of windows.
One is essentially just a normal firefox browser window,
either identical to firefox, or absent some UI elements.
But the other window must be completely borderless,
like tooltip windows. But mine needs to be able to
display HTML, including a few tiny icon-buttons on
the left followed by a variable length line of text.
And I need those windows to hide and display under
control of my extension without asking the user for
approval or anything. So far my attempts to create
completely borderless windows from javascript within
a window have failed (there's always the damn titlebar,
close button and resize-grips, even when I say not to
include these in the options in my window.open() call.
Supposedly javascript running in the chrome has
more complete "permissions", so maybe these
problems will vanish when I finally get a regular
extension working. I hope so, or I am ***screwed***.

====================================

On Mar 25, 2:10 am, Jonathan Protzenko <jonathan.protze...@gmail.com>
wrote:
> I don't know how I can provide a clearer answer:
> - either you do a restartless addon, and you use a technique
> such as https://github.com/protz/GMail-Conversation-View/blob/master/bootstra...
> to watch for new windows being opened and add your code into each one
> of them,
> - or you use the overlay mechanism to specify *which* window your
> <script> element should be added to.
>
> A <script> element isn't a useless UI element, it is the regular way to
> make your code run in a given window.
>
> Cheers,
>
> jonathan
>
> On Sun 25 Mar 2012 08:43:35 AM CEST, bootstrap wrote:
>
>
>
> > On Mar 24, 3:20 am, Jonathan Protzenko<jonathan.protze...@gmail.com>
> > wrote:
> >>https://developer.mozilla.org/en/Building_an_Extensionwillhelp you
> >>>https://lists.mozilla.org/listinfo/dev-extensions-Hide quoted text -

Neil

unread,
Mar 26, 2012, 10:11:52 AM3/26/12
to
bootstrap wrote:

>I mean, have YOU tried to create a regular extension that has an overlay that ONLY names a javascript file without any other XUL or UI element of any kind involved? If so, then I'm simply too stupid to guess the correct syntax for that from all the simple extension examples I've been working with.
>
<?xml version="1.0"?>
<overlay
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- example of inline script -->
<script type="application/javascript">
// You could put script here, but this confuses some editors.
</script>
<!-- example of separate script -->
<script type="application/javascript"
src="chrome://myext/content/myscript.js"/>
</overlay>

--
Warning: May contain traces of nuts.

bootstrap

unread,
Mar 26, 2012, 12:24:14 PM3/26/12
to
Damn! That sure looks like syntax I tried,
though I never tried the inline javascript,
and prefer not to.

Is there some reason that my javascript code
isn't receiving mousemove events? It was my
impression that the javascript in a regular
extension works just like javascript in the body
of every loaded document. Is that wrong?
Or is there something my javacript needs to
contain to make that work? I mean, if the
javascript doesn't have access to the window
(global object) of loaded documents, then what
use is javascript for working on the contents
of any loaded HTML documents? I'm confused!

Neil

unread,
Mar 26, 2012, 7:18:44 PM3/26/12
to
bootstrap wrote:

>Is there some reason that my javascript code isn't receiving mousemove events?
>
How are you listening for them?

bootstrap

unread,
Mar 27, 2012, 2:37:35 AM3/27/12
to
In the javascript file is:

window.onload = owl;
window.onmousemove = omm;

function owl (e) {
alert("meanings.js : function owl()");
return (0);
}

function omm (e) {
// alert("meanings.js : function omm()");
return (0);
}

Now that seems to work. I had an error in my "chrome.manifest" file.
My first line was:
content meanings meanings/content/
and should have been
content meanings content/

So probably the meanings/content/meanings.xul file wasn't found at
all.

Now I could probably make a bit of headway if only my dump(variable)
lines were working, but I can't find output anywhere.

Oh, one more thing. With the extension now sorta working (at least
the extension javascript is running),
much of the firefox browser UI has vanished. The main menu is still
there, and a text input field for entering
URLs is still there, but no page tabs, and none of my bookmarks. And
I notice many menu items no longer
exist (for example, under "Tools => WebDeveloper" there are two items
instead of the usual 8 or 10.
Did I somehow accidentally "overlay" a bunch of stuff somehow? Here
is my meanings.xul file in case
that's the source of the problem somehow:

-----
<?xml version="1.0"?>
<overlay id="meanings-overlay" xmlns="http://www.mozilla.org/keymaster/
gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://meanings/
content/meanings.js"/>
</overlay>
-----

Or maybe this the what is supposed to happen? When I run the default
profile, firefox appears as usual.
Only when I run the dev profile do I get this behavior, and only
since I fixed that path in chrome.manifest.

Here is the contents of the chrome.manifest file:
-----
content meanings content/
overlay chrome://browser/content/browser.xul chrome://meanings/content/meanings.xul
-----

Here is the content of the install.rdf file:
-----
<?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:type>2</em:type>
<em:name>meanings</em:name>
<em:unpack>true</em:unpack>
<em:bootstrap>false</em:bootstrap>
<em:id>mean...@meanings.com</em:id>
<em:version>0.0.0.201202290001</em:version>
<em:targetApplication>
<Description>
<em:id>too...@mozilla.org</em:id>
<em:minVersion>10.0</em:minVersion>
<em:maxVersion>12.0</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>
-----

I don't have anything in my defaults or skin directories.
No locale strings. No .css file. Not sure what I did to
make half the firefox UI vanish.

Thanks for your continued help.

Neil

unread,
Mar 27, 2012, 4:57:58 AM3/27/12
to
bootstrap wrote:

> window.onload = owl;
> window.onmousemove = omm;
>
>
You can't afford to overwrite global event listeners in your overlay,
particularly not the onload listener! Instead, use the addEventListener
method:

window.addEventListener("load", owl, false);
window.addEventListener("mousemove", omm, false);

bootstrap

unread,
Mar 28, 2012, 4:38:25 AM3/28/12
to
Yes, I totally agree. That was just to get me to the point
my extension javascript file was being invoked at all.

Changing to window.addEventListener() also made all the
lost UI elements return. I guess those simple event handlers
were canceling event ripple... or something.

I guess the next big advance will be figuring out debugging
with something better than alert() - which stops execution
in its tracks.

Any suggestions on the best set of tools to debug
javascript in regular extensions? I don't need anything
super fancy, but at least the ability to print messages
and variables to the "web-console" or "error console".
Or something like that.

Thanks. I'm on the verge of being able to "develop"!
0 new messages