I am working on adding support for Firefox 6 for my add-on on Mac OS, where the following logic is working in Firefox 4,5 versions but fails in Firefox 6.
XPCOM component has subclass of IObserverClient
and which adds itself as observer for a custom event.
This custom event is posted from browser overlay.js passing the selected browser's content window.
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
if (observerService) {
var data = gBrowser.selectedBrowser.contentWindow.location.href;
observerService.notifyObservers(gBrowser.selectedBrowser.contentWindow, JSEventTopic, data);
}
In XPCOM components handler, trying to get the nsIDOMWindow
interface from nsISupports
void XXX::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
{
nsCOMPtr<nsIDOMWindow> pWin;
aSubject->QueryInterface(nsIDOMWindow::GetIID(), getter_AddRefs(pWin));
}
The problem is, with Firefox 6 pWin
is nil. In Firefox 4 and 5 pWin
is as expected and not nil.