[Project_owners] Hooking HTTP Basic Authentication dialog

Michael Vincent mv_van_rantwijk at yahoo.com
Sat Sep 17 09:07:19 EDT 2005


Eric Jung wrote:
> Hi,
> 
> 
> --- Michael Vincent <mv_van_rantwijk at yahoo.com> wrote:
> 
>> Eric Jung wrote:
>>> Hi,
>>> I'd like my extension to be notified when an HTTP Basic
>>> Authentication dialog (like when you go here:
>>> http://passwordmaker.org:2082/) is displayed and be able to write
>> to
>>> the input boxes of this dialog.
>>>
>>> Does a standard pageLoad eventListener intercept this, or is it
>> more
>>> complex?
>>>
>>> Thanks for any advice,
>>> Eric Jung
>> FYI: that dialog is commonDialog.xul/commonDialog.js
>> and you can use  registerNotification in nsIWindowWatcher.idl
>>
> 
> OK, I'm getting notifications now but can't find references to the
> username & password input boxes:

You got the right window ID also?

> 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") {
>     domWindow = 
>       domWindow.QueryInterface(Components.interfaces.nsIDOMWindow);
>       var user = domWindow.document.getElementById("loginTextbox");
>       var pw = domWindow.document.getElementById("password1Textbox");
>       dump(user + "\n");
>       dump(pw + "\n");
>     }
>   },
> 
> This dumps null and null to the console.... :(

Yeah, you probably want to read nsIDialogParamBlock.idl and 
nsPIPromptService.idl first

> FWIW, I can't find commonDialog.xul/commonDialog.js in FF (but maybe
> I missed it?), just Mozilla.

Both are part of toolkit.jar and just remember that the DOM Inspector 
can be a good friend ;)

>> Yeah, I'm totally crazy to be still awake at 12:40AM, but I got the
>> day 
>> off tomorrow, and I still have to fix something ;)
>>
> 
> Heh. An all-night coding session. Those can be fun, but take care of
> your health.

Thanks, and I sure will ;)

Michael


More information about the Project_owners mailing list