javascript - Firefox add-on get the DOM window which made an HTTP request -


i'm capturing http requests in firefox add-on sdk extension. need dom window associated request. however, i'm getting ns_nointerface error.

here code:

  var httprequestobserver = {     observe: function (subject, topic, data) {       var httprequest = subject.queryinterface(ci.nsihttpchannel);       var requesturl = subject.uri.host;       var domwin;       var asswindow;       console.log('url: ', requesturl);       try {         domwin = httprequest.notificationcallbacks.getinterface(ci.nsidomwindow);         asswindow = httpchannel.notificationcallbacks.getinterface(ci.nsiloadcontext)                                .associatedwindow;         console.log(domwin);       } catch (e) {         console.log(e);       }       // console.log('tab: ', tabslib.gettabforwindow(domwin.top));        var hostname = wn.domwindow.getbrowser().selectedbrowser.contentwindow.location.host;       console.log('host: ', hostname);     },      observerservice() {       return cc['@mozilla.org/observer-service;1'].getservice(ci.nsiobserverservice);     },      register: function () {       this.observerservice.addobserver(this, 'http-on-modify-request', false);     },      unregister: function () {       this.observerservice.removeobserver(this, 'http-on-modify-request');     }   };    httprequestobserver.register(); 

i've tried both nsidomwindow , nsiloadcontext, ns_nointerface error appears on attempt window object.

i have managed data need via

httprequest.notificationcallbacks.getinterface(ci.nsiloadcontext).topframeelement 

for example, url of document started request, used

httprequest.notificationcallbacks.getinterface(ci.nsiloadcontext).topframeelement._documenturi.href 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -