From 78934dceb9dee799b07aedd8c3bdc1ddf42cae6c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 13 Nov 2015 12:22:08 +0800 Subject: [PATCH] Cleanup and docs for the --js-flags --- atom/browser/javascript_environment.cc | 17 +++++++---------- docs/api/chrome-command-line-switches.md | 9 +++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index ae4f8e55..dc27cede 100644 --- a/atom/browser/javascript_environment.cc +++ b/atom/browser/javascript_environment.cc @@ -2,11 +2,12 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. -#include - #include "atom/browser/javascript_environment.h" +#include + #include "base/command_line.h" +#include "content/public/common/content_switches.h" #include "gin/array_buffer.h" #include "gin/v8_initializer.h" @@ -30,17 +31,13 @@ bool JavascriptEnvironment::Initialize() { v8::V8::SetFlagsFromString(expose_debug_as, sizeof(expose_debug_as) - 1); } - const std::string js_flags_switch = "js-flags"; - - if (cmd->HasSwitch(js_flags_switch)) { - const char *js_flags_value = - (cmd->GetSwitchValueASCII(js_flags_switch)).c_str(); - v8::V8::SetFlagsFromString(js_flags_value, strlen(js_flags_value)); - } + // --js-flags. + std::string js_flags = cmd->GetSwitchValueASCII(switches::kJavaScriptFlags); + if (!js_flags.empty()) + v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size()); gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, gin::ArrayBufferAllocator::SharedInstance()); - return true; } diff --git a/docs/api/chrome-command-line-switches.md b/docs/api/chrome-command-line-switches.md index d163a726..c1adf3c4 100644 --- a/docs/api/chrome-command-line-switches.md +++ b/docs/api/chrome-command-line-switches.md @@ -31,6 +31,15 @@ Disables the disk cache for HTTP requests. Enables remote debugging over HTTP on the specified `port`. +## --js-flags=`flags` + +Specifies the flags passed to JS engine. It has to be passed when starting +Electron if you want to enable the `flags` in the main process. + +```bash +$ electron --js-flags="--harmony_proxies --harmony_collections" your-app +``` + ## --proxy-server=`address:port` Use a specified proxy server, which overrides the system setting. This switch -- 2.43.0