MozillaZine

Last browser window standing

Talk about add-ons and extension development.
asqueella
 
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post Posted October 7th, 2005, 12:40 am

* Don't try to use alert() as a test for the startup stuff - it doesn't work.

(You may have figured it out, but for future readers)
It's not just alert(). None of objects that are a property of window will work (e.g. <del>dump</del>, document.implementation, navigator, etc.). You can use the prompt service for alerts or console service for debugging messages.
And it's not just startup. It won't work in component code, because the global object for components is not window.

This should be on devmo or something.

Feel free to write an article and put it there :)
Turning that example in an article for devmo requires a non-zero amount of work.

[edit] dump() actually works in components, but it's not window.dump()
Last edited by asqueella on December 24th, 2005, 2:05 pm, edited 1 time in total.

azzer
 
Posts: 244
Joined: September 13th, 2005, 9:56 pm

Post Posted October 7th, 2005, 9:54 am

Hmmm. Anyone got this to work? I've grabbed the code, created a new GUID, added
Code: Select all
obsSvc.addObserver(this, "domwindowclosed", false);
to the "xpcom-startup' case of observe() and added
Code: Select all
case "domwindowclosed":
            
      var consoleService = Components.classes['@mozilla.org/consoleservice;1'] .getService(Components.interfaces.nsIConsoleService);
                        
      consoleService.logStringMessage("Test XPCom domwindowclosed");
      break;

I put the file in 'components' directory (parallel with 'contents', 'locale' etc), generated the XPI and installed in a fresh profile. Nothing! Worringly, I don't see the GUID in compreg.dat.

Am I doing anything wrong? And what's the significance of MY_OBSERVER_NAME?

Thanks,
Andy

[Edit]
Disregard stupid MY_OBSERVER_NAME question...

old np
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted October 7th, 2005, 11:47 am

Do the other topics (ex: profile-after-change) work?

azzer
 
Posts: 244
Joined: September 13th, 2005, 9:56 pm

Post Posted October 7th, 2005, 12:23 pm

No they don't.

old np
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted October 7th, 2005, 12:45 pm

Have you deleted compreg.dat? Does anything show in the console?

asqueella
 
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post Posted October 7th, 2005, 7:51 pm

Did you generate the GUID or used the xxxxxx one?

Did you install the XPI that had the components/ subfolder, or just created it in your profile? If the latter, you have to manually register it in some .ini file (components.ini?), at least in 1.0.

azzer
 
Posts: 244
Joined: September 13th, 2005, 9:56 pm

Post Posted October 11th, 2005, 9:27 pm

np: yes, no.
asqueella: I generated a valid GUID. I installed the XPI in a fresh profile, just to be sure.

I notice Forecastfox has some very small components that I could try out - I haven't had chance yet, but will try in the next day or so. If I can get those going, I should be able to figure out what's going on here...

asqueella
 
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post Posted October 12th, 2005, 2:20 am

azzer: you may have a syntax error in your JS somewhere, that would explain your problem.

OnlyMe
 
Posts: 34
Joined: February 16th, 2005, 11:59 am

Post Posted October 12th, 2005, 1:13 pm

Does anyone have list of topics which are fired on Thunderbirds startup, I'm looking for events after "profile-after-change" I need to load an RDF file but loading file this on "profile-after-change" causes TB to crash (iirc rdf::openmember ) when installing extensions.

asqueella
 
Posts: 4019
Joined: November 16th, 2003, 3:05 am
Location: Russia, Moscow

Post Posted October 12th, 2005, 3:40 pm

OnlyMe: If it crashes the latest nightly, file a bug.

OnlyMe
 
Posts: 34
Joined: February 16th, 2005, 11:59 am

Post Posted October 12th, 2005, 4:17 pm

asqueella wrote:OnlyMe: If it crashes the latest nightly, file a bug.


It crashes TB1.4 b2, I haven't tried it on anything more recent.

ericjung
 
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post Posted October 13th, 2005, 3:53 pm

azzer, please let those of us watching this thread when you've got it working. I need the same thing for PasswordMaker.

Thanks,
grimholtz

azzer
 
Posts: 244
Joined: September 13th, 2005, 9:56 pm

Post Posted October 13th, 2005, 5:09 pm

np wrote:Just some tips for future readers of this thread:

* When using it in your extension, create a "components" folder in the extension's root folder and put it in there.

Hmmm. Well clearly that caveat was a bit too complex for me. I read it, of course, absorbed that knowledge, and created 'components' under chrome... Do not do this at home kids: chrome and components should be at the same level in the xpi.

Arrghh!

Anway, having done that, it all worked perfectly per my original post in this thread ("Anybody got this to work?").

I think the thing is that it all looks very cryptic, but essentially everything after "/* Registration Code */ is boiler-plate.

I've grumbled about XUL JS data having window- rather than extension-wide scope before. This is the *correct* solution. Anything that should exist independently of windows should be in a component.

Now to refactor...
Andy

ericjung
 
Posts: 846
Joined: August 4th, 2003, 9:32 am

Post Posted October 13th, 2005, 7:57 pm

And what about people who are upgrading to an existing profile? Will the component register for them? (I suspect not since it's not a new profile)

azzer
 
Posts: 244
Joined: September 13th, 2005, 9:56 pm

Post Posted October 13th, 2005, 8:53 pm

I don't think upgrading should be a problem. Works fine installing a newer version on top of an old one.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest