diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index aee7235e75dd..6b7760f9ddcc 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -2293,6 +2293,21 @@ TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture) return IPC_OK(); } +// Return whether a remote script should be loaded in middleman processes in +// addition to any child recording process they have. +static bool +LoadScriptInMiddleman(const nsString& aURL) +{ + return // Middleman processes run devtools server side scripts. + StringBeginsWith(aURL, NS_LITERAL_STRING("resource://devtools/")) + // This script includes event listeners needed to propagate document + // title changes. + || aURL.EqualsLiteral("chrome://global/content/browser-child.js") + // This script is needed to respond to session store requests from the + // UI process. + || aURL.EqualsLiteral("chrome://browser/content/content-sessionStore.js"); +} + mozilla::ipc::IPCResult TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope) { @@ -2307,6 +2322,11 @@ TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalSco return IPC_OK(); } + // Make sure we only load whitelisted scripts in middleman processes. + if (recordreplay::IsMiddleman() && !LoadScriptInMiddleman(aURL)) { + return IPC_OK(); + } + LoadScriptInternal(global, aURL, aRunInGlobalScope); return IPC_OK(); }