refactor: use Node.js isolate setup in node mode (#23213)
This commit is contained in:
Родитель
a9c17610b5
Коммит
6a564af580
|
@ -2,45 +2,18 @@
|
|||
"abort/test-abort-backtrace",
|
||||
"async-hooks/test-crypto-pbkdf2",
|
||||
"async-hooks/test-crypto-randomBytes",
|
||||
"async-hooks/test-emit-after-on-destroyed",
|
||||
"async-hooks/test-emit-before-after",
|
||||
"async-hooks/test-emit-before-on-destroyed",
|
||||
"async-hooks/test-emit-init",
|
||||
"async-hooks/test-fseventwrap",
|
||||
"async-hooks/test-fsreqcallback-readFile",
|
||||
"async-hooks/test-getaddrinforeqwrap",
|
||||
"async-hooks/test-getnameinforeqwrap",
|
||||
"async-hooks/test-graph.signal",
|
||||
"async-hooks/test-improper-order",
|
||||
"async-hooks/test-late-hook-enable",
|
||||
"async-hooks/test-nexttick-default-trigger",
|
||||
"async-hooks/test-pipewrap",
|
||||
"async-hooks/test-promise",
|
||||
"async-hooks/test-queue-microtask",
|
||||
"async-hooks/test-signalwrap",
|
||||
"async-hooks/test-statwatcher",
|
||||
"async-hooks/test-timers.setInterval",
|
||||
"message/async_error_eval_esm",
|
||||
"message/esm_loader_not_found",
|
||||
"message/source_map_throw_catch",
|
||||
"message/source_map_throw_first_tick",
|
||||
"message/source_map_throw_set_immediate",
|
||||
"message/unhandled_promise_trace_warnings",
|
||||
"message/v8_warning",
|
||||
"parallel/test-assert",
|
||||
"parallel/test-async-hooks-close-during-destroy",
|
||||
"parallel/test-async-hooks-promise",
|
||||
"parallel/test-async-hooks-promise-triggerid",
|
||||
"parallel/test-async-hooks-top-level-clearimmediate",
|
||||
"parallel/test-bootstrap-modules",
|
||||
"parallel/test-buffer-backing-arraybuffer",
|
||||
"parallel/test-buffer-constructor-node-modules-paths",
|
||||
"parallel/test-buffer-constructor-outside-node-modules",
|
||||
"parallel/test-child-process-fork-exec-path",
|
||||
"parallel/test-cli-eval",
|
||||
"parallel/test-cli-node-print-help",
|
||||
"parallel/test-code-cache",
|
||||
"parallel/test-common-gc",
|
||||
"parallel/test-crypto",
|
||||
"parallel/test-crypto-aes-wrap",
|
||||
"parallel/test-crypto-authenticated",
|
||||
|
@ -67,23 +40,13 @@
|
|||
"parallel/test-debugger-pid",
|
||||
"parallel/test-domain-abort-on-uncaught",
|
||||
"parallel/test-domain-with-abort-on-uncaught-exception",
|
||||
"parallel/test-dummy-stdio",
|
||||
"parallel/test-finalization-group-error",
|
||||
"parallel/test-freeze-intrinsics",
|
||||
"parallel/test-fs-write-sigxfsz",
|
||||
"parallel/test-gc-tls-external-memory",
|
||||
"parallel/test-heapdump-async-hooks-init-promise",
|
||||
"parallel/test-http-agent-domain-reused-gc",
|
||||
"parallel/test-http-client-readable",
|
||||
"parallel/test-http2-compat-serverrequest-settimeout",
|
||||
"parallel/test-http2-compat-serverresponse-settimeout",
|
||||
"parallel/test-http2-reset-flood",
|
||||
"parallel/test-https-agent-session-reuse",
|
||||
"parallel/test-http2-reset-flood",
|
||||
"parallel/test-https-options-boolean-check",
|
||||
"parallel/test-inspector-async-hook-after-done",
|
||||
"parallel/test-inspector-esm",
|
||||
"parallel/test-inspector-heap-allocation-tracker",
|
||||
"parallel/test-inspector-heap-allocation-tracker",
|
||||
"parallel/test-inspector-multisession-ws",
|
||||
"parallel/test-inspector-port-zero-cluster",
|
||||
"parallel/test-inspector-tracing-domain",
|
||||
|
@ -184,28 +147,20 @@
|
|||
"parallel/test-util-inspect",
|
||||
"parallel/test-v8-coverage",
|
||||
"parallel/test-v8-flags",
|
||||
"parallel/test-vm-basic",
|
||||
"parallel/test-vm-module-basic",
|
||||
"parallel/test-vm-parse-abort-on-uncaught-exception",
|
||||
"parallel/test-vm-sigint",
|
||||
"parallel/test-vm-sigint-existing-handler",
|
||||
"parallel/test-vm-syntax-error-message",
|
||||
"parallel/test-vm-timeout",
|
||||
"parallel/test-whatwg-encoding-custom-textdecoder",
|
||||
"parallel/test-worker-debug",
|
||||
"parallel/test-worker-invalid-workerdata",
|
||||
"parallel/test-worker-message-channel",
|
||||
"parallel/test-worker-message-port",
|
||||
"parallel/test-worker-message-port-transfer-duplicate",
|
||||
"parallel/test-worker-message-port-transfer-target",
|
||||
"parallel/test-worker-ref-onexit",
|
||||
"parallel/test-worker-sharedarraybuffer-from-worker-thread",
|
||||
"parallel/test-worker-stdio",
|
||||
"parallel/test-wrap-js-stream-exceptions",
|
||||
"parallel/test-zlib-unused-weak",
|
||||
"pseudo-tty/test-set-raw-mode-reset-process-exit",
|
||||
"pseudo-tty/test-set-raw-mode-reset-signal",
|
||||
"sequential/test-child-process-execsync",
|
||||
"sequential/test-cpu-prof-default",
|
||||
"sequential/test-cpu-prof-dir-absolute",
|
||||
"sequential/test-cpu-prof-dir-and-name",
|
||||
|
@ -216,7 +171,6 @@
|
|||
"sequential/test-cpu-prof-kill",
|
||||
"sequential/test-cpu-prof-name",
|
||||
"sequential/test-cpu-prof-worker-argv",
|
||||
"sequential/test-fs-watch",
|
||||
"sequential/test-heap-prof",
|
||||
"sequential/test-heapdump",
|
||||
"sequential/test-heapdump-flag",
|
||||
|
@ -225,9 +179,6 @@
|
|||
"sequential/test-inspector-resource-name-to-url",
|
||||
"sequential/test-inspector-stress-http",
|
||||
"sequential/test-perf-hooks",
|
||||
"sequential/test-process-warnings",
|
||||
"sequential/test-timers-block-eventloop",
|
||||
"sequential/test-timers-set-interval-excludes-callback-duration",
|
||||
"sequential/test-tls-connect",
|
||||
"sequential/test-vm-timeout-rethrow",
|
||||
"wpt/test-encoding"
|
||||
|
|
|
@ -74,24 +74,6 @@ void SetNodeCliFlags() {
|
|||
ProcessGlobalArgs(&args, nullptr, &errors, node::kDisallowedInEnvironment);
|
||||
}
|
||||
|
||||
// TODO(codebytere): expose this from Node.js itself?
|
||||
void HostCleanupFinalizationGroupCallback(
|
||||
v8::Local<v8::Context> context,
|
||||
v8::Local<v8::FinalizationGroup> group) {
|
||||
node::Environment* env = node::Environment::GetCurrent(context);
|
||||
if (env == nullptr) {
|
||||
return;
|
||||
}
|
||||
env->RegisterFinalizationGroupForCleanup(group);
|
||||
}
|
||||
|
||||
bool AllowWasmCodeGenerationCallback(v8::Local<v8::Context> context,
|
||||
v8::Local<v8::String>) {
|
||||
v8::Local<v8::Value> wasm_code_gen = context->GetEmbedderData(
|
||||
node::ContextEmbedderIndex::kAllowWasmCodeGeneration);
|
||||
return wasm_code_gen->IsUndefined() || wasm_code_gen->IsTrue();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace electron {
|
||||
|
@ -126,6 +108,10 @@ int NodeMain(int argc, char* argv[]) {
|
|||
crash_reporter::CrashReporterWin::SetUnhandledExceptionFilter();
|
||||
#endif
|
||||
|
||||
// We do not want to double-set the error level and promise rejection
|
||||
// callback.
|
||||
node::g_standalone_mode = false;
|
||||
|
||||
// Explicitly register electron's builtin modules.
|
||||
NodeBindings::RegisterBuiltinModules();
|
||||
|
||||
|
@ -146,9 +132,6 @@ int NodeMain(int argc, char* argv[]) {
|
|||
JavascriptEnvironment gin_env(loop);
|
||||
|
||||
v8::Isolate* isolate = gin_env.isolate();
|
||||
// TODO(ckerr) and/or TODO(codebytere) use node::SetIsolateMiscHandlers()
|
||||
node::IsolateSettings is;
|
||||
isolate->SetMicrotasksPolicy(is.policy);
|
||||
|
||||
v8::Isolate::Scope isolate_scope(isolate);
|
||||
v8::Locker locker(isolate);
|
||||
|
@ -167,13 +150,8 @@ int NodeMain(int argc, char* argv[]) {
|
|||
// This needs to be called before the inspector is initialized.
|
||||
env->InitializeDiagnostics();
|
||||
|
||||
// This is needed in order to enable v8 host weakref hooks.
|
||||
// TODO(codebytere): we shouldn't have to call this - upstream?
|
||||
isolate->SetHostCleanupFinalizationGroupCallback(
|
||||
HostCleanupFinalizationGroupCallback);
|
||||
|
||||
isolate->SetAllowWasmCodeGenerationCallback(
|
||||
AllowWasmCodeGenerationCallback);
|
||||
node::IsolateSettings is;
|
||||
node::SetIsolateUpForNode(isolate, is);
|
||||
|
||||
gin_helper::Dictionary process(isolate, env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
|
|
|
@ -26,11 +26,7 @@ namespace electron {
|
|||
|
||||
class NodeBindings {
|
||||
public:
|
||||
enum class BrowserEnvironment {
|
||||
BROWSER,
|
||||
RENDERER,
|
||||
WORKER,
|
||||
};
|
||||
enum class BrowserEnvironment { BROWSER, RENDERER, WORKER };
|
||||
|
||||
static NodeBindings* Create(BrowserEnvironment browser_env);
|
||||
static void RegisterBuiltinModules();
|
||||
|
|
Загрузка…
Ссылка в новой задаче