0

を行うために取得し、それはFirefoxウィンドウの特定のタブにテキスト入力プロセッサを使用することは可能ですか?タブのnsIDOMWindowは、テキスト入力

すべてのタブは同じnsIDOMWindowオブジェクトを共有していますか?もしそうなら、他の解決策はありますか?私の問題を言い換え

:私は特定のタブにテキストを入力したい、そして1以上が存在する場合、それは、現在ではないかもしれません。以下

はなく、現在のタブのための、任意のFirefoxウィンドウにテキストを書き込むコード例である:

function myTestFunc() { 
    // var windows = Services.wm.getEnumerator("navigation:browser"); 
    var windows = require("sdk/windows"); 
    for (let browserWindow of windows.browserWindows) { 
    //console.log(window.title); 
    var chromeWindow = viewFor(browserWindow); 
    console.log(chromeWindow.document.location.href); 
    var idomWindow = chromeWindow.QueryInterface(Ci.nsIDOMWindow); 

    var TIP = Cc["@mozilla.org/text-input-processor;1"]. 
       createInstance(Ci.nsITextInputProcessor); 
    if(!TIP.beginInputTransaction(idomWindow, onNotifyImpl)) { 
     console.log("Error TIP can't start"); 
     continue; 
    } 
    TIP.setPendingCompositionString("foo-bar-buzz"); 
    if (!TIP.flushPendingComposition()) { 
     console.log("Failed to flush"); 
     continue; // Composition is not started 
    } 
    } 

} 

答えて

1

nsIDOMWindow(+ docshellとのような様々な関連インターフェイス)はで正規windowオブジェクトのXPCOM表現でありますw3cの仕様。また、ウィンドウオブジェクトはネストすることができるので(iframe経由など)、nsIDOMWindowsでも構いません。ブラウザウィンドウにアクセスしているときは、通常、コンテンツではなくブラウザのクロムを表す外側のウィンドウにアクセスしています。

原則として、<browser> XUL要素から直接タブのコンテンツウィンドウにアクセスできますが、代わりにframescriptsを使用する必要があります。

+0

あなたは私が '' XUL要素からそれをアセスんどのように手の込んだてもらえますか?残念ながら、私の使用例では、framescriptsはオプションではありません。 – alandarev

+0

私はe10s互換性を損なうアドオンの作成をサポートするつもりはありません。代わりに、あなたがフレームスクリプトを使用できないと信じている理由を説明してください。 – the8472

+0

それすべてはここから始まった:http://stackoverflow.com/questions/11456705/are-events-generated-by-firefox-extension-trusted/11461469#comment58574373_11461469私が持っているキーボードイベントを生成する必要が 'isTrusted = true'をプロパティ。 – alandarev

関連する問題