+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/api/command-line-switches.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ Set the directory to which all Node.js diagnostic output files are written. Defa

Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https://nodejs.org/docs/latest/api/v8.html#v8setheapsnapshotnearheaplimitlimit).

### `--no-experimental-global-navigator`

Disable exposition of [Navigator API][] on the global scope from Node.js.

[app]: app.md
[append-switch]: command-line.md#commandlineappendswitchswitch-value
[debugging-main-process]: ../tutorial/debugging-main-process.md
Expand All @@ -333,3 +337,4 @@ Affects the default output directory of [v8.setHeapSnapshotNearHeapLimit](https:
[play-silent-audio]: https://github.com/atom/atom/pull/9485/files
[ready]: app.md#event-ready
[severities]: https://source.chromium.org/chromium/chromium/src/+/main:base/logging.h?q=logging::LogSeverity&ss=chromium
[Navigator API]: https://github.com/nodejs/node/blob/main/doc/api/globals.md#navigator
1 change: 1 addition & 0 deletions shell/common/node_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ bool IsAllowedOption(const std::string_view option) {
"--throw-deprecation",
"--trace-deprecation",
"--trace-warnings",
"--no-experimental-global-navigator",
});

if (debug_options.contains(option))
Expand Down
28 changes: 28 additions & 0 deletions spec/api-utility-process-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,5 +780,33 @@ describe('utilityProcess module', () => {
expect(stat.size).to.be.greaterThan(0);
await fs.rm(tmpDir, { recursive: true });
});

it('supports --no-experimental-global-navigator flag', async () => {
{
const child = utilityProcess.fork(path.join(fixturesPath, 'navigator.js'), [], {
stdio: 'ignore'
});
await once(child, 'spawn');
const [data] = await once(child, 'message');
expect(data).to.be.true();
const exit = once(child, 'exit');
expect(child.kill()).to.be.true();
await exit;
}
{
const child = utilityProcess.fork(path.join(fixturesPath, 'navigator.js'), [], {
stdio: 'ignore',
execArgv: [
'--no-experimental-global-navigator'
]
});
await once(child, 'spawn');
const [data] = await once(child, 'message');
expect(data).to.be.false();
const exit = once(child, 'exit');
expect(child.kill()).to.be.true();
await exit;
}
});
});
});
1 change: 1 addition & 0 deletions spec/fixtures/api/utility-process/navigator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
process.parentPort.postMessage(typeof navigator === 'object');
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载