]> khamidou — GitHub mirrors - electron.git/commitdiff
Add --js-flags support for main thread.
authorShawn K <skhameneh@gmail.com>
Thu, 12 Nov 2015 09:00:41 +0000 (01:00 -0800)
committerShawn K <skhameneh@gmail.com>
Thu, 12 Nov 2015 09:48:23 +0000 (01:48 -0800)
Allow use of flags that must be set before V8 is initialized, such as
"--harmony_proxies", e.g. --js-flags="--harmony_proxies
--harmony_collections"

atom/browser/javascript_environment.cc

index cc06bb6ff9c23cf4e78d3812648bc164327d54ac..ae4f8e55e76e81166aa9d66dff46449c701af3f3 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by the MIT license that can be
 // found in the LICENSE file.
 
+#include <string>
+
 #include "atom/browser/javascript_environment.h"
 
 #include "base/command_line.h"
@@ -27,8 +29,18 @@ bool JavascriptEnvironment::Initialize() {
     const char expose_debug_as[] = "--expose_debug_as=v8debug";
     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));
+  }
+
   gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
                                  gin::ArrayBufferAllocator::SharedInstance());
+
   return true;
 }