raghavan.s
2011-04-04 06:47:51 UTC
Hi,
I posted this question in mozilla.dev.embedding and got no response.
Trying my luck here,
I am embedding xulrunner in a java application. The application will
launch new window with some URL to measure performance
metrics like DNS time, Connection time, Time to First byte , Time to
last byte, Start render time and document complete.
I used following code to launch the window:
nsIThread thread = threadMgr.getMainThread();
windowWatcher =
(nsIWindowWatcher)serviceManager.getServiceByContractID("@mozilla.org/
embedcomp/window-watcher;1",nsIWindowWatcher.NS_IWINDOWWATCHER_IID);
nsIWindowWatcher watcherProxy =
(nsIWindowWatcher)proxy.getProxyForObject(thread,nsIWindowWatcher.NS_IWINDOWWATCHER_IID,windowWatcher,nsIProxyObjectManager.INVOKE_SYNC);
nsIDOMWindow window=watcherProxy.openWindow(null,
"about:blank","window1",
"chrome,centerscreen,resizable,width=1024,height=768", null);
nsIInterfaceRequestor ir = (nsIInterfaceRequestor)
window.queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
nsIWebNavigation webNav
=(nsIWebNavigation)ir.getInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
nsIWebNavigation webNavProxy =
(nsIWebNavigation)proxy.getProxyForObject(thread,nsIWebNavigation.NS_IWEBNAVIGATION_IID,webNav,nsIProxyObjectManager.INVOKE_SYNC);
webNavProxy.loadURI(url,nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY,
null, postDataStream, headers);
I added listener for the events MozAfterPaint, DomContentLoaded, Load
as below using
nsIWindowMediatorListener windowMediator.addListener(this);
public void onOpenWindow(nsIXULWindow xulWin)
{
nsIDOMWindow window = (nsIDOMWindow)
((nsIInterfaceRequestor)xulWin.getDocShell().queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)).getInterface(nsIDOMWindow.NS_IDOMWINDOW
_IID);
nsIDOMEventTarget winTarget =
(nsIDOMEventTarget)window.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
winTarget.addEventListener("MozAfterPaint",this,true); //want
to notified the event in capturing phase.
winTarget.addEventListener("load",this,true);
winTarget.addEventListener("DOMContentLoaded",this,true);
}
I am able to get notification for the url given in
windowWatcher.openWindow. For the URL loaded via
nsIWebNavigation.LoadURI, i am not getting notified.
Am i doing anything wrong while adding the event listeners ?
Kindly help me to resolve this.
Regards,
Raghavan
I posted this question in mozilla.dev.embedding and got no response.
Trying my luck here,
I am embedding xulrunner in a java application. The application will
launch new window with some URL to measure performance
metrics like DNS time, Connection time, Time to First byte , Time to
last byte, Start render time and document complete.
I used following code to launch the window:
nsIThread thread = threadMgr.getMainThread();
windowWatcher =
(nsIWindowWatcher)serviceManager.getServiceByContractID("@mozilla.org/
embedcomp/window-watcher;1",nsIWindowWatcher.NS_IWINDOWWATCHER_IID);
nsIWindowWatcher watcherProxy =
(nsIWindowWatcher)proxy.getProxyForObject(thread,nsIWindowWatcher.NS_IWINDOWWATCHER_IID,windowWatcher,nsIProxyObjectManager.INVOKE_SYNC);
nsIDOMWindow window=watcherProxy.openWindow(null,
"about:blank","window1",
"chrome,centerscreen,resizable,width=1024,height=768", null);
nsIInterfaceRequestor ir = (nsIInterfaceRequestor)
window.queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID);
nsIWebNavigation webNav
=(nsIWebNavigation)ir.getInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
nsIWebNavigation webNavProxy =
(nsIWebNavigation)proxy.getProxyForObject(thread,nsIWebNavigation.NS_IWEBNAVIGATION_IID,webNav,nsIProxyObjectManager.INVOKE_SYNC);
webNavProxy.loadURI(url,nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY,
null, postDataStream, headers);
I added listener for the events MozAfterPaint, DomContentLoaded, Load
as below using
nsIWindowMediatorListener windowMediator.addListener(this);
public void onOpenWindow(nsIXULWindow xulWin)
{
nsIDOMWindow window = (nsIDOMWindow)
((nsIInterfaceRequestor)xulWin.getDocShell().queryInterface(nsIInterfaceRequestor.NS_IINTERFACEREQUESTOR_IID)).getInterface(nsIDOMWindow.NS_IDOMWINDOW
_IID);
nsIDOMEventTarget winTarget =
(nsIDOMEventTarget)window.queryInterface(nsIDOMEventTarget.NS_IDOMEVENTTARGET_IID);
winTarget.addEventListener("MozAfterPaint",this,true); //want
to notified the event in capturing phase.
winTarget.addEventListener("load",this,true);
winTarget.addEventListener("DOMContentLoaded",this,true);
}
I am able to get notification for the url given in
windowWatcher.openWindow. For the URL loaded via
nsIWebNavigation.LoadURI, i am not getting notified.
Am i doing anything wrong while adding the event listeners ?
Kindly help me to resolve this.
Regards,
Raghavan