[Project_owners] http-on-examine-response, page titles

Adam Judson adamsplugins at gmail.com
Wed Sep 14 11:54:39 EDT 2005


There is code in tamperdata (tamperdata.mozdev.org) to associate load
events with observed requests.

Yes it is a pain.

Basically I match the URI and hope for the best.  If the user opens the
same page in multiple tabs, or hits refresh a lot, I'd expect things to break.

If you add the on loadf handler in a browser overlay, you'll get it
for every page.

Also keep in mind that on-examine-response doesn't fire if the page
is retrieved from the cache, also I don't think onload fires for redirects, as a
page isn't really loaded.

You may also want to look at adblock.  Maybe you can solve your
problem with content
handlers (or whatever they're called).

Adam


On 14/09/05, Stan James <sjames at uni-osnabrueck.de> wrote:
> Hi all,
> 
> I'm using an observer to get notified of all HTTP events, but am having
> trouble getting the page titles of successfully loaded pages. I need to
> track the redirects leading up to the final page, and then be able to
> identify the whole sequence by the title of the resulting page.
> 
> I can set up an oberserver like this:
>         var observerService =
> 
> Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
>         observerService.addObserver(gMyObserver,
> "http-on-examine-response", false);
> 
> With an oberver like this:
>     var gMyObserver =
>     {
>         observe : function(aHttpChannel, aTopic, aData)
>         {
> 
> 
> aHttpChannel.QueryInterface(Components.interfaces.nsIHttpChannel);
> 
>             // we only care about document loading events
>             if (!(aHttpChannel.loadFlags &
> aHttpChannel.LOAD_DOCUMENT_URI)) return;
> 
>             var uri =    aHttpChannel.URI.spec;
>             var responseStatus =     aHttpChannel.responseStatus;
>             var requestMethod = aHttpChannel.requestMethod;
> 
>             // do more stuff...
>         }
>     };
> 
> But then there seems no way to access any info about the loaded page
> from the channel object. I can use a normal onload events to grab the
> page title, but then it's a real bitch to associate it with the correct
> http events...plus the fact that the observer works cross-window while
> onload events are window-specific.
> 
> Any ideas? Thanks for any help!
> 
> -stan
> 
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>


More information about the Project_owners mailing list