2014-01-13 29 views
5

私は、次のコードを使用してブラウザのタブでのXMLHttpRequestを関連付けしようとしていますから、タブを取得:Firefoxのアドオン:XMLHttpRequestを

GETINTERFACE(Ci.nsILoadContextが)で失敗し

function getBrowserFromChannel(aChannel) { 
    var notificationCallbacks = 
     aChannel.notificationCallbacks ? 
        aChannel.notificationCallbacks : 
        aChannel.loadGroup.notificationCallbacks; 

    if (!notificationCallbacks) { 
     console.log("no callbacks"); 
     return (0); 
    } 
    var loadContext = notificationCallbacks.getInterface(Ci.nsILoadContext); 
:「コンポーネントが要求されていていませんインターフェース "

他にどのようにブラウザを手に入れることができますか?

おかげ

答えて

1

このコード(from Lightbeam)してみてください:ライセンスはMPL 1.1

function getLoadContext(aRequest) { 
    try { 
     // first try the notification callbacks 
     var loadContext = aRequest.QueryInterface(Ci.nsIChannel) 
      .notificationCallbacks.getInterface(Ci.nsILoadContext); 
     return loadContext; 
    } catch (ex) { 
     // fail over to trying the load group 
     try { 
      if (!aRequest.loadGroup) return null; 

      var loadContext = aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext); 
      return loadContext; 
     } catch (ex) { 
      return null; 
     } 
    } 
} 

注/ GPL 2.0/LGPL 2.1

関連する問題