Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make certain values on process read-only #15628

Merged
merged 2 commits into from Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions atom/common/api/atom_bindings.cc
Expand Up @@ -72,19 +72,18 @@ void AtomBindings::BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process) {
base::Unretained(this)));

#if defined(MAS_BUILD)
dict.Set("mas", true);
dict.SetReadOnly("mas", true);
#endif

#if defined(OS_WIN)
if (IsRunningInDesktopBridge())
dict.Set("windowsStore", true);
dict.SetReadOnly("windowsStore", true);
#endif

mate::Dictionary versions;
if (dict.Get("versions", &versions)) {
// TODO(kevinsawicki): Make read-only in 2.0 to match node
versions.Set(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
versions.Set("chrome", CHROME_VERSION_STRING);
versions.SetReadOnly(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
versions.SetReadOnly("chrome", CHROME_VERSION_STRING);
}
}

Expand Down
2 changes: 1 addition & 1 deletion atom/common/node_bindings.cc
Expand Up @@ -339,7 +339,7 @@ node::Environment* NodeBindings::CreateEnvironment(
}

mate::Dictionary process(context->GetIsolate(), env->process_object());
process.Set("type", process_type);
process.SetReadOnly("type", process_type);
process.Set("resourcesPath", resources_path);
// Do not set DOM globals for renderer process.
if (browser_env_ != BROWSER)
Expand Down
10 changes: 5 additions & 5 deletions atom/renderer/atom_sandboxed_renderer_client.cc
Expand Up @@ -158,18 +158,18 @@ void AtomSandboxedRendererClient::InitializeBindings(

process.Set("argv", base::CommandLine::ForCurrentProcess()->argv());
process.Set("execPath", GetExecPath());
process.Set("pid", base::GetCurrentProcId());
process.SetReadOnly("pid", base::GetCurrentProcId());
process.Set("resourcesPath", NodeBindings::GetHelperResourcesPath());
process.Set("sandboxed", true);
process.Set("type", "renderer");
process.SetReadOnly("sandboxed", true);
process.SetReadOnly("type", "renderer");

#if defined(MAS_BUILD)
process.Set("mas", true);
process.SetReadOnly("mas", true);
#endif

#if defined(OS_WIN)
if (IsRunningInDesktopBridge())
process.Set("windowsStore", true);
process.SetReadOnly("windowsStore", true);
#endif

// Pass in CLI flags needed to setup the renderer
Expand Down
2 changes: 1 addition & 1 deletion docs/api/process.md
Expand Up @@ -103,7 +103,7 @@ A `Boolean` that controls whether or not process warnings printed to `stderr` in

### `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`

Expand Down