Merge pull request #8852 from electron/web-worker-hook
Add Node.js integration to WebWorker
This commit is contained in:
commit
e539129db2
35 changed files with 408 additions and 64 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/command_line.h"
|
||||
|
@ -60,8 +61,8 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
|||
: fake_browser_process_(new BrowserProcess),
|
||||
exit_code_(nullptr),
|
||||
browser_(new Browser),
|
||||
node_bindings_(NodeBindings::Create(true)),
|
||||
atom_bindings_(new AtomBindings),
|
||||
node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)),
|
||||
atom_bindings_(new AtomBindings(uv_default_loop())),
|
||||
gc_timer_(true, true) {
|
||||
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
||||
self_ = this;
|
||||
|
@ -71,6 +72,7 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
|||
}
|
||||
|
||||
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
||||
asar::ClearArchives();
|
||||
// Leak the JavascriptEnvironment on exit.
|
||||
// This is to work around the bug that V8 would be waiting for background
|
||||
// tasks to finish on exit, while somehow it waits forever in Electron, more
|
||||
|
|
|
@ -97,6 +97,10 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|||
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
||||
node_integration ? "true" : "false");
|
||||
|
||||
// Whether to enable node integration in Worker.
|
||||
if (web_preferences.GetBoolean(options::kNodeIntegrationInWorker, &b) && b)
|
||||
command_line->AppendSwitch(switches::kNodeIntegrationInWorker);
|
||||
|
||||
// If the `sandbox` option was passed to the BrowserWindow's webPreferences,
|
||||
// pass `--enable-sandbox` to the renderer so it won't have any node.js
|
||||
// integration.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue