fix: make certain values on process
read-only (#15628)
* docs: Add 'worker' as a possible value for `process.type` * fix: make certain properties on `process` read only: * `mas` * `windowsStore` * `versions.electron` * `versions.chrome` * `type` * `pid` * `sandboxed`
This commit is contained in:
parent
4e53019b75
commit
2a8e8a0603
4 changed files with 11 additions and 12 deletions
|
@ -72,19 +72,18 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
|
||||||
base::Unretained(this)));
|
base::Unretained(this)));
|
||||||
|
|
||||||
#if defined(MAS_BUILD)
|
#if defined(MAS_BUILD)
|
||||||
dict.Set("mas", true);
|
dict.SetReadOnly("mas", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (IsRunningInDesktopBridge())
|
if (IsRunningInDesktopBridge())
|
||||||
dict.Set("windowsStore", true);
|
dict.SetReadOnly("windowsStore", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mate::Dictionary versions;
|
mate::Dictionary versions;
|
||||||
if (dict.Get("versions", &versions)) {
|
if (dict.Get("versions", &versions)) {
|
||||||
// TODO(kevinsawicki): Make read-only in 2.0 to match node
|
versions.SetReadOnly(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
|
||||||
versions.Set(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
|
versions.SetReadOnly("chrome", CHROME_VERSION_STRING);
|
||||||
versions.Set("chrome", CHROME_VERSION_STRING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ node::Environment* NodeBindings::CreateEnvironment(
|
||||||
}
|
}
|
||||||
|
|
||||||
mate::Dictionary process(context->GetIsolate(), env->process_object());
|
mate::Dictionary process(context->GetIsolate(), env->process_object());
|
||||||
process.Set("type", process_type);
|
process.SetReadOnly("type", process_type);
|
||||||
process.Set("resourcesPath", resources_path);
|
process.Set("resourcesPath", resources_path);
|
||||||
// Do not set DOM globals for renderer process.
|
// Do not set DOM globals for renderer process.
|
||||||
if (browser_env_ != BROWSER)
|
if (browser_env_ != BROWSER)
|
||||||
|
|
|
@ -158,18 +158,18 @@ void AtomSandboxedRendererClient::InitializeBindings(
|
||||||
|
|
||||||
process.Set("argv", base::CommandLine::ForCurrentProcess()->argv());
|
process.Set("argv", base::CommandLine::ForCurrentProcess()->argv());
|
||||||
process.Set("execPath", GetExecPath());
|
process.Set("execPath", GetExecPath());
|
||||||
process.Set("pid", base::GetCurrentProcId());
|
process.SetReadOnly("pid", base::GetCurrentProcId());
|
||||||
process.Set("resourcesPath", NodeBindings::GetHelperResourcesPath());
|
process.Set("resourcesPath", NodeBindings::GetHelperResourcesPath());
|
||||||
process.Set("sandboxed", true);
|
process.SetReadOnly("sandboxed", true);
|
||||||
process.Set("type", "renderer");
|
process.SetReadOnly("type", "renderer");
|
||||||
|
|
||||||
#if defined(MAS_BUILD)
|
#if defined(MAS_BUILD)
|
||||||
process.Set("mas", true);
|
process.SetReadOnly("mas", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (IsRunningInDesktopBridge())
|
if (IsRunningInDesktopBridge())
|
||||||
process.Set("windowsStore", true);
|
process.SetReadOnly("windowsStore", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Pass in CLI flags needed to setup the renderer
|
// Pass in CLI flags needed to setup the renderer
|
||||||
|
|
|
@ -103,7 +103,7 @@ A `Boolean` that controls whether or not process warnings printed to `stderr` in
|
||||||
|
|
||||||
### `process.type`
|
### `process.type`
|
||||||
|
|
||||||
A `String` representing the current process's type, can be `"browser"` (i.e. main process) or `"renderer"`.
|
A `String` representing the current process's type, can be `"browser"` (i.e. main process), `"renderer"`, or `"worker"` (i.e. web worker).
|
||||||
|
|
||||||
### `process.versions.chrome`
|
### `process.versions.chrome`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue