Your problem is that myExt is a singleton yet you try to set myExt.Main
to something different for each window, only the last thing you set to
myExt.Main will stick.
On 12/29/11 12:40, foudfou wrote:
>> Sorry I'm too lazy to download and extract an XPI.
>
> <!-- overlay.xul -->
> <?xml version="1.0"?>
> <overlay id="xulschoolhello-browser-overlay"
> xmlns="
http://www.mozilla.org/keymaster/gatekeeper/
> there.is.only.xul">
>
> <script type="application/x-javascript">
> Components.utils.import("resource://myext/commons.js");
>
> myExt.Main = {
> onQuit: function(win) {
> alert("UNLOADED");
> },
> }
Here you are updating the myExt singleton with a new object that has the
current window as its parent. Everytime this code runs (for every
browser window opened) it replaces the current myExt.Main with the new
object. So "alert" here tries to call "alert" on the last browser window
that was opened. If that browser window is no longer around (i.e. if you
close the second browser window then close the first browser window)
then alert would be undefined.
I imagine if you did win.alert it would work fine because you are
passing in a live window, the one that is currently closing.
Not sure what the end goal here is but the correct thing to do is define
myExt.Main in the JSM in the first place rather than redefine it
everytime a browser window is opened, that is bound to lead to confusing
problems like this.