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 by asqueella »

* 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
Contact:

Post by azzer »

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 by old np »

Do the other topics (ex: profile-after-change) work?
azzer
Posts: 244
Joined: September 13th, 2005, 9:56 pm
Contact:

Post by azzer »

No they don't.
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

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 by asqueella »

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
Contact:

Post by azzer »

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 by asqueella »

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 by OnlyMe »

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 by asqueella »

OnlyMe: If it crashes the latest nightly, file a bug.
OnlyMe
Posts: 34
Joined: February 16th, 2005, 11:59 am

Post by OnlyMe »

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 by ericjung »

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
Contact:

Post by azzer »

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 by ericjung »

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
Contact:

Post by azzer »

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