rem: var wWatcher = Components.classes[ "@mozilla.org/embedcomp/window-watcher;1"] .getService( Components.interfaces.nsIWindowWatcher ); var gAlarmWindow = wWatcher.getWindowByName( "calendar-alarm-window", null); 
add:  var wMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); var gAlarmWindow = wMediator.getMostRecentWindow("calendarAlarmWindow"); 
context:     onAlarm: function( event ) {        //If an event has alarm email address, we assume the alarm is of email        //type.  See similar note in eventDialog.js        if(event.alarmEmailAddress && event.alarmEmailAddress != "") {            //XXX Re-implement this!            return;        }        //The alarm dialog will play a sound, but if it isn't opened, we need        //to play a sound on our own here.        var prefService = Components.classes["@mozilla.org/preferences-service;1"]                          .getService(Components.interfaces.nsIPrefService);        var calendarPrefs = prefService.getBranch("calendar.alarms.");        if(!calendarPrefs.getBoolPref("show") &&            calendarPrefs.getBoolPref("playsound")) {            playSound();            return;        }        //Check to see if an alarm window already exists.  It not, create it.        var wWatcher = Components.classes[                       "@mozilla.org/embedcomp/window-watcher;1"]                       .getService( Components.interfaces.nsIWindowWatcher );        var gAlarmWindow = wWatcher.getWindowByName( "calendar-alarm-window", null);        if( !gAlarmWindow ) {            gAlarmWindow = wWatcher.openWindow(null,                                               "chrome://calendar/content/calendar-alarm-dialog.xul",                                               "_blank",                                               "chrome,dialog=yes,all",                                                null);            gAlarmWindow.name = "calendar-alarm-window";        }        gAlarmWindow.focus();        if ("addAlarm" in gAlarmWindow) {            gAlarmWindow.addAlarm(event);        }         else {            var addAlarm = function() {                gAlarmWindow.addAlarm( event );            }            gAlarmWindow.addEventListener("load", addAlarm, false);        }    }
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/9421/4f56aac4f7354320a768cf94d7ff368714289fdc/calAlarmMonitor.js/buggy/calendar/resources/content/calAlarmMonitor.js