build: remove enable_run_as_node build flag (#38413)
* feat: remove enable_run_as_node flag * drop features.isRunAsNodeEnabled() * use IsEnvSet() helper in electron_main_linux.cc * cleanup [[maybe_unused]] --------- Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
parent
806f00285c
commit
05d39d8313
18 changed files with 29 additions and 96 deletions
|
@ -175,9 +175,6 @@ env-mac-large-release: &env-mac-large-release
|
||||||
env-ninja-status: &env-ninja-status
|
env-ninja-status: &env-ninja-status
|
||||||
NINJA_STATUS: "[%r processes, %f/%t @ %o/s : %es] "
|
NINJA_STATUS: "[%r processes, %f/%t @ %o/s : %es] "
|
||||||
|
|
||||||
env-disable-run-as-node: &env-disable-run-as-node
|
|
||||||
GN_BUILDFLAG_ARGS: 'enable_run_as_node = false'
|
|
||||||
|
|
||||||
env-32bit-release: &env-32bit-release
|
env-32bit-release: &env-32bit-release
|
||||||
# Set symbol level to 1 for 32 bit releases because of https://crbug.com/648948
|
# Set symbol level to 1 for 32 bit releases because of https://crbug.com/648948
|
||||||
GN_BUILDFLAG_ARGS: 'symbol_level = 1'
|
GN_BUILDFLAG_ARGS: 'symbol_level = 1'
|
||||||
|
@ -1730,23 +1727,6 @@ jobs:
|
||||||
artifact-key: 'linux-x64-asan'
|
artifact-key: 'linux-x64-asan'
|
||||||
build-type: 'Linux'
|
build-type: 'Linux'
|
||||||
|
|
||||||
linux-x64-testing-no-run-as-node:
|
|
||||||
executor:
|
|
||||||
name: linux-docker
|
|
||||||
size: xlarge
|
|
||||||
environment:
|
|
||||||
<<: *env-linux-2xlarge
|
|
||||||
<<: *env-testing-build
|
|
||||||
<<: *env-ninja-status
|
|
||||||
<<: *env-disable-run-as-node
|
|
||||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
|
||||||
steps:
|
|
||||||
- electron-build:
|
|
||||||
persist: false
|
|
||||||
checkout: true
|
|
||||||
artifact-key: 'linux-x64-no-run-as-node'
|
|
||||||
build-type: 'Linux'
|
|
||||||
|
|
||||||
linux-x64-testing-gn-check:
|
linux-x64-testing-gn-check:
|
||||||
executor:
|
executor:
|
||||||
name: linux-docker
|
name: linux-docker
|
||||||
|
@ -2230,9 +2210,6 @@ workflows:
|
||||||
- linux-x64-testing-asan:
|
- linux-x64-testing-asan:
|
||||||
requires:
|
requires:
|
||||||
- linux-make-src-cache
|
- linux-make-src-cache
|
||||||
- linux-x64-testing-no-run-as-node:
|
|
||||||
requires:
|
|
||||||
- linux-make-src-cache
|
|
||||||
- linux-x64-testing-gn-check:
|
- linux-x64-testing-gn-check:
|
||||||
requires:
|
requires:
|
||||||
- linux-make-src-cache
|
- linux-make-src-cache
|
||||||
|
|
7
BUILD.gn
7
BUILD.gn
|
@ -669,13 +669,6 @@ source_set("electron_lib") {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_run_as_node) {
|
|
||||||
sources += [
|
|
||||||
"shell/app/node_main.cc",
|
|
||||||
"shell/app/node_main.h",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enable_osr) {
|
if (enable_osr) {
|
||||||
sources += [
|
sources += [
|
||||||
"shell/browser/osr/osr_host_display_client.cc",
|
"shell/browser/osr/osr_host_display_client.cc",
|
||||||
|
|
|
@ -9,7 +9,6 @@ buildflag_header("buildflags") {
|
||||||
header = "buildflags.h"
|
header = "buildflags.h"
|
||||||
|
|
||||||
flags = [
|
flags = [
|
||||||
"ENABLE_RUN_AS_NODE=$enable_run_as_node",
|
|
||||||
"ENABLE_OSR=$enable_osr",
|
"ENABLE_OSR=$enable_osr",
|
||||||
"ENABLE_VIEWS_API=$enable_views_api",
|
"ENABLE_VIEWS_API=$enable_views_api",
|
||||||
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
|
"ENABLE_PDF_VIEWER=$enable_pdf_viewer",
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
declare_args() {
|
declare_args() {
|
||||||
# Allow running Electron as a node binary.
|
|
||||||
enable_run_as_node = true
|
|
||||||
|
|
||||||
enable_osr = true
|
enable_osr = true
|
||||||
|
|
||||||
enable_views_api = true
|
enable_views_api = true
|
||||||
|
|
|
@ -237,6 +237,8 @@ filenames = {
|
||||||
"shell/app/electron_crash_reporter_client.h",
|
"shell/app/electron_crash_reporter_client.h",
|
||||||
"shell/app/electron_main_delegate.cc",
|
"shell/app/electron_main_delegate.cc",
|
||||||
"shell/app/electron_main_delegate.h",
|
"shell/app/electron_main_delegate.h",
|
||||||
|
"shell/app/node_main.cc",
|
||||||
|
"shell/app/node_main.h",
|
||||||
"shell/app/uv_task_runner.cc",
|
"shell/app/uv_task_runner.cc",
|
||||||
"shell/app/uv_task_runner.h",
|
"shell/app/uv_task_runner.h",
|
||||||
"shell/browser/api/electron_api_app.cc",
|
"shell/browser/api/electron_api_app.cc",
|
||||||
|
|
|
@ -11,12 +11,9 @@
|
||||||
#if BUILDFLAG(IS_MAC)
|
#if BUILDFLAG(IS_MAC)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__attribute__((visibility("default"))) int ElectronMain(int argc, char* argv[]);
|
__attribute__((visibility("default"))) int ElectronMain(int argc, char* argv[]);
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
|
||||||
__attribute__((visibility("default"))) int ElectronInitializeICUandStartNode(
|
__attribute__((visibility("default"))) int ElectronInitializeICUandStartNode(
|
||||||
int argc,
|
int argc,
|
||||||
char* argv[]);
|
char* argv[]);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ int ElectronMain(int argc, char* argv[]) {
|
||||||
return content::ContentMain(std::move(params));
|
return content::ContentMain(std::move(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
|
||||||
int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
|
int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
|
||||||
if (!electron::fuses::IsRunAsNodeEnabled()) {
|
if (!electron::fuses::IsRunAsNodeEnabled()) {
|
||||||
CHECK(false) << "run_as_node fuse is disabled";
|
CHECK(false) << "run_as_node fuse is disabled";
|
||||||
|
@ -43,4 +42,3 @@ int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
|
||||||
base::i18n::InitializeICU();
|
base::i18n::InitializeICU();
|
||||||
return electron::NodeMain(argc, argv);
|
return electron::NodeMain(argc, argv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -18,18 +18,23 @@
|
||||||
#include "shell/common/electron_command_line.h"
|
#include "shell/common/electron_command_line.h"
|
||||||
#include "shell/common/electron_constants.h"
|
#include "shell/common/electron_constants.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
bool IsEnvSet(const char* name) {
|
||||||
|
char* indicator = getenv(name);
|
||||||
|
return indicator && indicator[0] != '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
FixStdioStreams();
|
FixStdioStreams();
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
|
||||||
char* indicator = getenv(electron::kRunAsNode);
|
|
||||||
if (electron::fuses::IsRunAsNodeEnabled() && indicator &&
|
|
||||||
indicator[0] != '\0') {
|
|
||||||
base::i18n::InitializeICU();
|
base::i18n::InitializeICU();
|
||||||
base::AtExitManager atexit_manager;
|
base::AtExitManager atexit_manager;
|
||||||
return electron::NodeMain(argc, argv);
|
return electron::NodeMain(argc, argv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
electron::ElectronMainDelegate delegate;
|
electron::ElectronMainDelegate delegate;
|
||||||
content::ContentMainParams params(&delegate);
|
content::ContentMainParams params(&delegate);
|
||||||
|
|
|
@ -28,7 +28,7 @@ void abort_report_np(const char* fmt, ...);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
[[maybe_unused]] bool IsEnvSet(const char* name) {
|
bool IsEnvSet(const char* name) {
|
||||||
char* indicator = getenv(name);
|
char* indicator = getenv(name);
|
||||||
return indicator && indicator[0] != '\0';
|
return indicator && indicator[0] != '\0';
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,10 @@ int main(int argc, char* argv[]) {
|
||||||
partition_alloc::EarlyMallocZoneRegistration();
|
partition_alloc::EarlyMallocZoneRegistration();
|
||||||
FixStdioStreams();
|
FixStdioStreams();
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
|
||||||
if (electron::fuses::IsRunAsNodeEnabled() &&
|
if (electron::fuses::IsRunAsNodeEnabled() &&
|
||||||
IsEnvSet("ELECTRON_RUN_AS_NODE")) {
|
IsEnvSet("ELECTRON_RUN_AS_NODE")) {
|
||||||
return ElectronInitializeICUandStartNode(argc, argv);
|
return ElectronInitializeICUandStartNode(argc, argv);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD()
|
||||||
uint32_t exec_path_size = 0;
|
uint32_t exec_path_size = 0;
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace {
|
||||||
const char kUserDataDir[] = "user-data-dir";
|
const char kUserDataDir[] = "user-data-dir";
|
||||||
const char kProcessType[] = "type";
|
const char kProcessType[] = "type";
|
||||||
|
|
||||||
[[maybe_unused]] bool IsEnvSet(const char* name) {
|
bool IsEnvSet(const char* name) {
|
||||||
size_t required_size;
|
size_t required_size;
|
||||||
getenv_s(&required_size, nullptr, 0, name);
|
getenv_s(&required_size, nullptr, 0, name);
|
||||||
return required_size != 0;
|
return required_size != 0;
|
||||||
|
@ -150,12 +150,8 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
|
||||||
bool run_as_node =
|
bool run_as_node =
|
||||||
electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode);
|
electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode);
|
||||||
#else
|
|
||||||
bool run_as_node = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Make sure the output is printed to console.
|
// Make sure the output is printed to console.
|
||||||
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
if (run_as_node || !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE"))
|
||||||
|
@ -164,15 +160,13 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
std::vector<char*> argv(arguments.argc);
|
std::vector<char*> argv(arguments.argc);
|
||||||
std::transform(arguments.argv, arguments.argv + arguments.argc, argv.begin(),
|
std::transform(arguments.argv, arguments.argv + arguments.argc, argv.begin(),
|
||||||
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
|
[](auto& a) { return _strdup(base::WideToUTF8(a).c_str()); });
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
if (run_as_node) {
|
||||||
if (electron::fuses::IsRunAsNodeEnabled() && run_as_node) {
|
|
||||||
base::AtExitManager atexit_manager;
|
base::AtExitManager atexit_manager;
|
||||||
base::i18n::InitializeICU();
|
base::i18n::InitializeICU();
|
||||||
auto ret = electron::NodeMain(argv.size(), argv.data());
|
auto ret = electron::NodeMain(argv.size(), argv.data());
|
||||||
std::for_each(argv.begin(), argv.end(), free);
|
std::for_each(argv.begin(), argv.end(), free);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
base::CommandLine::Init(argv.size(), argv.data());
|
base::CommandLine::Init(argv.size(), argv.data());
|
||||||
const base::CommandLine* command_line =
|
const base::CommandLine* command_line =
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "electron/buildflags/buildflags.h"
|
#include "electron/buildflags/buildflags.h"
|
||||||
#include "electron/fuses.h"
|
|
||||||
#include "printing/buildflags/buildflags.h"
|
#include "printing/buildflags/buildflags.h"
|
||||||
#include "shell/common/gin_helper/dictionary.h"
|
#include "shell/common/gin_helper/dictionary.h"
|
||||||
#include "shell/common/node_includes.h"
|
#include "shell/common/node_includes.h"
|
||||||
|
@ -22,10 +21,6 @@ bool IsPDFViewerEnabled() {
|
||||||
return BUILDFLAG(ENABLE_PDF_VIEWER);
|
return BUILDFLAG(ENABLE_PDF_VIEWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsRunAsNodeEnabled() {
|
|
||||||
return electron::fuses::IsRunAsNodeEnabled() && BUILDFLAG(ENABLE_RUN_AS_NODE);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsFakeLocationProviderEnabled() {
|
bool IsFakeLocationProviderEnabled() {
|
||||||
return BUILDFLAG(OVERRIDE_LOCATION_PROVIDER);
|
return BUILDFLAG(OVERRIDE_LOCATION_PROVIDER);
|
||||||
}
|
}
|
||||||
|
@ -58,7 +53,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
||||||
dict.SetMethod("isBuiltinSpellCheckerEnabled", &IsBuiltinSpellCheckerEnabled);
|
dict.SetMethod("isBuiltinSpellCheckerEnabled", &IsBuiltinSpellCheckerEnabled);
|
||||||
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
|
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
|
||||||
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
|
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
|
||||||
dict.SetMethod("isRunAsNodeEnabled", &IsRunAsNodeEnabled);
|
|
||||||
dict.SetMethod("isFakeLocationProviderEnabled",
|
dict.SetMethod("isFakeLocationProviderEnabled",
|
||||||
&IsFakeLocationProviderEnabled);
|
&IsFakeLocationProviderEnabled);
|
||||||
dict.SetMethod("isViewApiEnabled", &IsViewApiEnabled);
|
dict.SetMethod("isViewApiEnabled", &IsViewApiEnabled);
|
||||||
|
|
|
@ -97,14 +97,8 @@ void GetCrashKeys(std::map<std::string, std::string>* keys) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool IsRunningAsNode() {
|
bool IsRunningAsNode() {
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
return electron::fuses::IsRunAsNodeEnabled() &&
|
||||||
if (!electron::fuses::IsRunAsNodeEnabled())
|
base::Environment::Create()->HasVar(electron::kRunAsNode);
|
||||||
return false;
|
|
||||||
|
|
||||||
return base::Environment::Create()->HasVar(electron::kRunAsNode);
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,7 @@ const char kDeviceVendorIdKey[] = "vendorId";
|
||||||
const char kDeviceProductIdKey[] = "productId";
|
const char kDeviceProductIdKey[] = "productId";
|
||||||
const char kDeviceSerialNumberKey[] = "serialNumber";
|
const char kDeviceSerialNumberKey[] = "serialNumber";
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
|
||||||
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
|
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
const char kPDFExtensionPluginName[] = "Chromium PDF Viewer";
|
const char kPDFExtensionPluginName[] = "Chromium PDF Viewer";
|
||||||
|
|
|
@ -20,9 +20,7 @@ extern const char kDeviceVendorIdKey[];
|
||||||
extern const char kDeviceProductIdKey[];
|
extern const char kDeviceProductIdKey[];
|
||||||
extern const char kDeviceSerialNumberKey[];
|
extern const char kDeviceSerialNumberKey[];
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_RUN_AS_NODE)
|
|
||||||
extern const char kRunAsNode[];
|
extern const char kRunAsNode[];
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||||
extern const char kPDFExtensionPluginName[];
|
extern const char kPDFExtensionPluginName[];
|
||||||
|
|
|
@ -8,8 +8,6 @@ import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from '
|
||||||
import * as importedFs from 'fs';
|
import * as importedFs from 'fs';
|
||||||
import { once } from 'events';
|
import { once } from 'events';
|
||||||
|
|
||||||
const features = process._linkedBinding('electron_common_features');
|
|
||||||
|
|
||||||
describe('asar package', () => {
|
describe('asar package', () => {
|
||||||
const fixtures = path.join(__dirname, 'fixtures');
|
const fixtures = path.join(__dirname, 'fixtures');
|
||||||
const asarDir = path.join(fixtures, 'test.asar');
|
const asarDir = path.join(fixtures, 'test.asar');
|
||||||
|
@ -1222,7 +1220,7 @@ describe('asar package', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(features.isRunAsNodeEnabled())('child_process.fork', function () {
|
describe('child_process.fork', function () {
|
||||||
itremote('opens a normal js file', async function () {
|
itremote('opens a normal js file', async function () {
|
||||||
const child = require('child_process').fork(path.join(asarDir, 'a.asar', 'ping.js'));
|
const child = require('child_process').fork(path.join(asarDir, 'a.asar', 'ping.js'));
|
||||||
child.send('message');
|
child.send('message');
|
||||||
|
@ -1410,12 +1408,6 @@ describe('asar package', function () {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
describe('process.env.ELECTRON_NO_ASAR', function () {
|
describe('process.env.ELECTRON_NO_ASAR', function () {
|
||||||
before(function () {
|
|
||||||
if (!features.isRunAsNodeEnabled()) {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
itremote('disables asar support in forked processes', function (done) {
|
itremote('disables asar support in forked processes', function (done) {
|
||||||
const forked = ChildProcess.fork(path.join(__dirname, 'fixtures', 'module', 'no-asar.js'), [], {
|
const forked = ChildProcess.fork(path.join(__dirname, 'fixtures', 'module', 'no-asar.js'), [], {
|
||||||
env: {
|
env: {
|
||||||
|
@ -1509,7 +1501,7 @@ describe('asar package', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
ifit(features.isRunAsNodeEnabled())('is available in forked scripts', async function () {
|
it('is available in forked scripts', async function () {
|
||||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'));
|
const child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'));
|
||||||
const message = once(child, 'message');
|
const message = once(child, 'message');
|
||||||
child.send('message');
|
child.send('message');
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { once } from 'events';
|
||||||
|
|
||||||
const Module = require('module');
|
const Module = require('module');
|
||||||
|
|
||||||
const features = process._linkedBinding('electron_common_features');
|
|
||||||
const nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS;
|
const nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS;
|
||||||
|
|
||||||
describe('modules support', () => {
|
describe('modules support', () => {
|
||||||
|
@ -28,7 +27,7 @@ describe('modules support', () => {
|
||||||
).to.be.fulfilled();
|
).to.be.fulfilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
ifit(features.isRunAsNodeEnabled())('can be required in node binary', async function () {
|
it('can be required in node binary', async function () {
|
||||||
const child = childProcess.fork(path.join(fixtures, 'module', 'echo.js'));
|
const child = childProcess.fork(path.join(fixtures, 'module', 'echo.js'));
|
||||||
const [msg] = await once(child, 'message');
|
const [msg] = await once(child, 'message');
|
||||||
expect(msg).to.equal('ok');
|
expect(msg).to.equal('ok');
|
||||||
|
@ -60,7 +59,7 @@ describe('modules support', () => {
|
||||||
await expect(w.webContents.executeJavaScript('{ require(\'@electron-ci/uv-dlopen\'); null }')).to.be.fulfilled();
|
await expect(w.webContents.executeJavaScript('{ require(\'@electron-ci/uv-dlopen\'); null }')).to.be.fulfilled();
|
||||||
});
|
});
|
||||||
|
|
||||||
ifit(features.isRunAsNodeEnabled())('can be required in node binary', async function () {
|
it('can be required in node binary', async function () {
|
||||||
const child = childProcess.fork(path.join(fixtures, 'module', 'uv-dlopen.js'));
|
const child = childProcess.fork(path.join(fixtures, 'module', 'uv-dlopen.js'));
|
||||||
const [exitCode] = await once(child, 'exit');
|
const [exitCode] = await once(child, 'exit');
|
||||||
expect(exitCode).to.equal(0);
|
expect(exitCode).to.equal(0);
|
||||||
|
|
|
@ -8,7 +8,6 @@ import { webContents } from 'electron/main';
|
||||||
import { EventEmitter } from 'stream';
|
import { EventEmitter } from 'stream';
|
||||||
import { once } from 'events';
|
import { once } from 'events';
|
||||||
|
|
||||||
const features = process._linkedBinding('electron_common_features');
|
|
||||||
const mainFixturesPath = path.resolve(__dirname, 'fixtures');
|
const mainFixturesPath = path.resolve(__dirname, 'fixtures');
|
||||||
|
|
||||||
describe('node feature', () => {
|
describe('node feature', () => {
|
||||||
|
@ -26,7 +25,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(features.isRunAsNodeEnabled())('child_process in renderer', () => {
|
describe('child_process in renderer', () => {
|
||||||
useRemoteContext();
|
useRemoteContext();
|
||||||
|
|
||||||
describe('child_process.fork', () => {
|
describe('child_process.fork', () => {
|
||||||
|
@ -360,7 +359,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(features.isRunAsNodeEnabled() && process.platform === 'darwin')('net.connect', () => {
|
ifdescribe(process.platform === 'darwin')('net.connect', () => {
|
||||||
itremote('emit error when connect to a socket path without listeners', async (fixtures: string) => {
|
itremote('emit error when connect to a socket path without listeners', async (fixtures: string) => {
|
||||||
const socketPath = require('path').join(require('os').tmpdir(), 'electron-test.sock');
|
const socketPath = require('path').join(require('os').tmpdir(), 'electron-test.sock');
|
||||||
const script = require('path').join(fixtures, 'module', 'create_socket.js');
|
const script = require('path').join(fixtures, 'module', 'create_socket.js');
|
||||||
|
@ -660,7 +659,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(features.isRunAsNodeEnabled())('Node.js cli flags', () => {
|
describe('Node.js cli flags', () => {
|
||||||
let child: childProcess.ChildProcessWithoutNullStreams;
|
let child: childProcess.ChildProcessWithoutNullStreams;
|
||||||
let exitPromise: Promise<any[]>;
|
let exitPromise: Promise<any[]>;
|
||||||
|
|
||||||
|
@ -713,7 +712,7 @@ describe('node feature', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ifdescribe(features.isRunAsNodeEnabled())('inspector', () => {
|
describe('inspector', () => {
|
||||||
let child: childProcess.ChildProcessWithoutNullStreams;
|
let child: childProcess.ChildProcessWithoutNullStreams;
|
||||||
let exitPromise: Promise<any[]> | null;
|
let exitPromise: Promise<any[]> | null;
|
||||||
|
|
||||||
|
@ -856,7 +855,7 @@ describe('node feature', () => {
|
||||||
expect(result.status).to.equal(0);
|
expect(result.status).to.equal(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
ifit(features.isRunAsNodeEnabled())('handles Promise timeouts correctly', async () => {
|
it('handles Promise timeouts correctly', async () => {
|
||||||
const scriptPath = path.join(fixtures, 'module', 'node-promise-timer.js');
|
const scriptPath = path.join(fixtures, 'module', 'node-promise-timer.js');
|
||||||
const child = childProcess.spawn(process.execPath, [scriptPath], {
|
const child = childProcess.spawn(process.execPath, [scriptPath], {
|
||||||
env: { ELECTRON_RUN_AS_NODE: 'true' }
|
env: { ELECTRON_RUN_AS_NODE: 'true' }
|
||||||
|
|
1
typings/internal-ambient.d.ts
vendored
1
typings/internal-ambient.d.ts
vendored
|
@ -7,7 +7,6 @@ declare namespace NodeJS {
|
||||||
isBuiltinSpellCheckerEnabled(): boolean;
|
isBuiltinSpellCheckerEnabled(): boolean;
|
||||||
isOffscreenRenderingEnabled(): boolean;
|
isOffscreenRenderingEnabled(): boolean;
|
||||||
isPDFViewerEnabled(): boolean;
|
isPDFViewerEnabled(): boolean;
|
||||||
isRunAsNodeEnabled(): boolean;
|
|
||||||
isFakeLocationProviderEnabled(): boolean;
|
isFakeLocationProviderEnabled(): boolean;
|
||||||
isViewApiEnabled(): boolean;
|
isViewApiEnabled(): boolean;
|
||||||
isPrintingEnabled(): boolean;
|
isPrintingEnabled(): boolean;
|
||||||
|
|
Loading…
Reference in a new issue