[Project_owners] HTTP Auth's opening URL

Eric Jung grimholtz at yahoo.com
Tue Sep 27 16:25:15 EDT 2005


Thanks, but in FF aXULWindow.docshell doesn't to contain anything.
The following dumps empty/nothing. Anyone have other ideas?

const gWindowManagerListener = {
  onOpenWindow: function(aXULWindow) {
    for (i in aXULWindow.docshell)
      dump(i + "=" + aXULWindow.docshell[i] + "\n");
    dump("======================================");
  },
  onCloseWindow: function(aXULWindow) {},
  onWindowTitleChange: function(aXULWindow, aWindowTitle) {}
};

const gWindowManager = 
  Components.classes['@mozilla.org/appshell/window-mediator;1']
  .getService(Components.interfaces.nsIWindowMediator);

gWindowManager.addListener(gWindowManagerListener);



--- Michael Vincent <mv_van_rantwijk at yahoo.com> wrote:

> Eric Jung wrote:
> > Hi,
> > My extension is watching for HTTP Basic Authorization dialog
> prompts
> > with the following code. I'm trying to determine the URL to which
> the
> > dialog attached, but
> > aEvent.currentTarget.opener.content.document.location is not
> reliable
> > when multiple tabs are open.
> > 
> > var watcher =
> >   Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
> >   .createInstance(Components.interfaces.nsIWindowWatcher);
> >   watcher.registerNotification(this);
> > 
> > observe : function(domWindow, topic, data) {
> >   if (topic == "domwindowopened") {
> >     // wait for xul to load
> >     domWindow.addEventListener("load", this.onNewWnd, true);
> >   }
> > },
> > 
> > onNewWnd : function(aEvent) {
> >   var wnd = aEvent.currentTarget;
> >   if (wnd.document.getElementById("commonDialog") != null) {
> >     if (wnd.opener.content) {      
> >       dump("wnd.opener.content.document.location+"\n");
> >     }
> >   }
> > }
> > 
> > Does anyone know what I might be doing wrong?
> > 
> > Thanks in advance for any help,
> > Eric
> 
> Don't use that, but use something similar like this instead:
> 
> const gWindowManager = 
> Components.classes['@mozilla.org/appshell/window-mediator;1']
>  
> .getService(Components.interfaces.nsIWindowMediator);
> 
> const gWindowManagerListener =
> {
>    onOpenWindow: function(aXULWindow) {},
>    onCloseWindow: function(aXULWindow) {},
>    onWindowTitleChange: function(aXULWindow, aWindowTitle) {}
> };
> 
> gWindowManager.addListener(gWindowManagerListener);
> gWindowManager.removeListener(gWindowManagerListener);
> 
> ...and the 'magic' is: aXULWindow.docShell;
> because that ultimately leads to anything you want...like the tab, 
> browser, uri, chrome window...you name it. It's all there ;)
> 
> Michael
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 



		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com


More information about the Project_owners mailing list