Bug 1809518 - Use stencil parsing to do the Javascript check for ORB in Utility Process r=farre,smaug,tcampbell

This patch allows JS Validator to parse the incoming data into
stencil to verify if its a Javascript file.

Differential Revision: https://phabricator.services.mozilla.com/D166484
This commit is contained in:
Sean Feng
2023-02-22 14:07:46 +00:00
parent 9d3852ab2f
commit 1d02f7f219
10 changed files with 152 additions and 41 deletions

View File

@@ -110,6 +110,15 @@ bool UtilityProcessChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
mSandbox = (SandboxingKind)aSandboxingKind;
// At the moment, only ORB uses JSContext in the
// Utility Process and ORB uses GENERIC_UTILITY
if (mSandbox == SandboxingKind::GENERIC_UTILITY) {
JS::DisableJitBackend();
if (!JS_Init()) {
return false;
}
}
profiler_set_process_name(nsCString("Utility Process"));
// Notify the parent process that we have finished our init and that it can
@@ -117,9 +126,12 @@ bool UtilityProcessChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint,
SendInitCompleted();
RunOnShutdown(
[] {
[sandboxKind = mSandbox] {
StaticMutexAutoLock lock(sUtilityProcessChildMutex);
sUtilityProcessChild = nullptr;
if (sandboxKind == SandboxingKind::GENERIC_UTILITY) {
JS_ShutDown();
}
},
ShutdownPhase::XPCOMShutdownFinal);