This is because you don't QueryInterface the subject for nsIChannel
(the interface from where the URI.spec come from). Since Firebug does
that and Firebug's observer is probably called before yours, the
underlying js wrapper already expose the interface and so, it works
even for you if Firebug is there.
Try the following in your code (notice that 'instanceof' does the
querying for you):
I believe this should solve the problem.
Honza
var httpRequestObserver =
{
observe: function(aSubject, aTopic, aData)
{
if (aSubject instanceof Ci.nsIChannel) //
Log("Hearing something : " + aSubject);
},
QueryInterface : function (iid) {
if (iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsIObserverService))
return this;
throw Cr.NS_NOINTERFACE;
}
};
On 24 Bře, 14:29, Pinetree <[email protected]> wrote:
> Hello all,
>
> I am writing an extension that has to capture all incoming data (page
> sources and image bytes). The excellent
> tutorialhttp://www.softwareishard.com/blog/firebug/nsitraceablechannel-interc...
> got me started, and everything is working as it should.
> That is, until i uninstall the firebug extension (because I can not
> assume that my users will have this installed).
>
> My httpRequestObserver object still "hears" the incoming connections,
> but it doesn't hear it in the same way as when firebug is installed.
> My code is herehttp://pastebin.com/fd2442f6(i removed all non-
> relevant parts)
>
> With firebug installed I get
> 13:24:17 Hearing something : [xpconnect wrapped (nsISupports,
> nsIHttpChannel, nsIRequest)]
> 13:25:16 Hearing something : [xpconnect wrapped (nsISupports,
> nsIHttpChannel, nsIChannel)]
> All subject.URI.spec data is set and everything is there, it all works
>
> Without firebug I get
> 14:10:14 Hearing something : [xpconnect wrapped nsISupports]
> 14:10:15 Hearing something : [xpconnect wrapped nsISupports]
> subject is null (or empty) and thus subject.URI.spec is not present.
>
> I have no idea what causes this, as the code is the same for firebug
> and for my extension. It must be something that firebug does globally
> (and that I am missing), because otherwise there would be no change in
> behaviour. But i have no clue where to begin to look.
> Can anyone give some advice?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---