特定のネットワーク負荷の検出と中止に依存する既存の Firefox 拡張機能を拡張しようとしていnsIContentPolicy
ます (結果として生じる UI アクション、つまりタブ ナビゲーションをブロックするため)。次に、そのリソースのロードを内部的に処理します。まれな状況では、ロードを処理した後で、ロードをまったく中断すべきではなかったことが判明したため、無視するようにフラグを立てて再開します。
e10s/マルチプロセスでは、親 (コンテンツ ポリシーが実行されている場所) がメッセージを子 (コンテンツの UI を処理している) に送信して、ロードを再開する必要があることを意味します。今日、それは以下によって行われます:
function findMessageManager(aContext) {
// With e10s off, context is a <browser> with a direct reference to
// the docshell loaded therein.
var docShell = aContext && aContext.docShell;
if (!docShell) {
// But with e10s on, context is a content window and we have to work hard
// to find the docshell, from which we can find the message manager.
docShell = aContext
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem).rootTreeItem;
}
try {
return docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIContentFrameMessageManager);
} catch (e) {
return null;
}
};
e10sは非常に複雑であるため、これは非常に複雑です。しかし、それは機能します。親でオブジェクトを生成し、その上で を呼び出す.sendAsyncMessage()
とaddMessageListener()
、フレーム/子スクリプトのハンドラーがそれを受け取り、必要な処理を実行します。
より良い判断 (この負荷をブロックして処理しますか?) を行うためのより多くの情報が表示されるため、からnsIContentPolicy
に切り替えたいと思います。http-on-modify-request
そのオブザーバー内で私ができること:
var browser = httpChannel
.notificationCallbacks.getInterface(Ci.nsILoadContext)
.topFrameElement;
これにより、ある種のメッセージマネージャーであり、.messageManager
メソッドを持つオブジェクトが得られます。しかし、それを使用すると、メッセージが消え、子供に見られることはありません。.sendAsyncMessage()
.sendAsyncMessage()
コンテキスト: https://github.com/greasemonkey/greasemonkey/issues/2280