Files
Netcatty/electron/preloadPath.test.cjs
T
陈大猫 52dfe7b524 perf(memory): implement Phase 1–2 idle, window, and terminal memory optimizations
- Fix kittyKeyboardBroadcast closure leak while preserving hibernated broadcast via detached top-level handler
- Replace dense KeywordHighlighter line caches with sparse packed triples and 53-bit numeric fingerprints
- Deduplicate hibernation snapshots and compress large scrollbacks via native gzip
- Eliminate cold-start terminalWorker wakes (portForwarding, transfer concurrency, empty monitor updates, cold MCP cancel, and stateless local shell/path queries)
- Auto-destroy hidden Settings and Tray windows after a configurable 20s idle grace window
- Tune Electron V8/GPU startup flags, switch V8 cache to code, and stream large app:// assets
- Split renderer entry bundle (App, NotesManager, MonitorPanels, globalAgentToolSpecs) and enable Chromium sandbox: true on all BrowserWindows via esbuild-bundled preload and IPC upload staging
- Add MRU=1 hidden WebGL context budget, dynamic main-window backgroundThrottling, bounded SSH/Fig caches, and lazy native addon loading
2026-11-27 08:28:48 +00:00

39 lines
1.6 KiB
JavaScript

"use strict";
const assert = require("node:assert/strict");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const test = require("node:test");
const {
PRELOAD_BUNDLE_FILENAME,
PRELOAD_SOURCE_FILENAME,
isBundledPreloadPath,
resolvePreloadPath,
resolvePreloadWebPreferences,
} = require("./preloadPath.cjs");
test("resolvePreloadPath prefers preload.bundle.cjs when present and falls back to preload.cjs", async (t) => {
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "netcatty-preload-path-"));
t.after(() => fs.promises.rm(dir, { recursive: true, force: true }));
assert.equal(resolvePreloadPath(dir), path.join(dir, PRELOAD_SOURCE_FILENAME));
assert.equal(isBundledPreloadPath(path.join(dir, PRELOAD_SOURCE_FILENAME)), false);
const bundlePath = path.join(dir, PRELOAD_BUNDLE_FILENAME);
await fs.promises.writeFile(bundlePath, "// bundle\n");
assert.equal(resolvePreloadPath(dir), bundlePath);
assert.equal(isBundledPreloadPath(bundlePath), true);
});
test("resolvePreloadWebPreferences enables sandbox for bundled preload and passes os release", () => {
const bundledPrefs = resolvePreloadWebPreferences("/app/electron/preload.bundle.cjs");
assert.equal(bundledPrefs.sandbox, true);
assert.deepEqual(bundledPrefs.additionalArguments, [`--netcatty-os-release=${os.release()}`]);
const sourcePrefs = resolvePreloadWebPreferences("/app/electron/preload.cjs");
assert.equal(sourcePrefs.sandbox, false);
assert.deepEqual(sourcePrefs.additionalArguments, [`--netcatty-os-release=${os.release()}`]);
});