Bug 1481352 - Add whitelist for remote scripts that can run in middleman processes, r=mccr8.

--HG--
extra : rebase_source : 9eabb532e1e310711777b14cd8a21881b646deca
This commit is contained in:
Brian Hackett 2018-08-14 00:43:24 +00:00
Родитель 60fcac25d8
Коммит 4cf0d8901e
1 изменённых файлов: 20 добавлений и 0 удалений

Просмотреть файл

@ -2293,6 +2293,21 @@ TabChild::RecvActivateFrameEvent(const nsString& aType, const bool& capture)
return IPC_OK(); 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 mozilla::ipc::IPCResult
TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope) TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalScope)
{ {
@ -2307,6 +2322,11 @@ TabChild::RecvLoadRemoteScript(const nsString& aURL, const bool& aRunInGlobalSco
return IPC_OK(); 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); LoadScriptInternal(global, aURL, aRunInGlobalScope);
return IPC_OK(); return IPC_OK();
} }