mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 12:01:13 +00:00
* fix(theme): broadcast native system theme updates to renderers nativeTheme.updated only fires for listeners in the main process, so a renderer sitting in system mode never learned that Windows changed the application theme. Forward the resolved preference to every window and let the settings hook re-apply it. * fix(theme): keep terminal chrome separate from native system policy refreshActiveChromeThemeSurfaces called setTheme(light|dark), which the main process writes into nativeTheme.themeSource. The stored preference stayed 'system' while Electron was pinned to a fixed color, so Windows application theme changes were ignored. Only paint the surfaces here. Also re-assert a fixed independent terminal theme when the OS preference changes: the fingerprint short-circuit skipped the refresh, and the hook effect never re-ran while the terminal props stayed stable. * test(theme): bound the new jsdom chrome tests A hanging jsdom/React render should fail the test with its name instead of consuming the CI job budget. * test(theme): provide native theme in bridge registrar fixtures * test(theme): provide nativeTheme in child-process registrar fixture The worker tests introduced in #4127 omitted nativeTheme after the system-theme listener registration became part of the production registrar. Provide a real EventEmitter, matching the transfer-limit fixture, so registrar setup succeeds without weakening production behavior. * ci: retrigger lint-and-test after runner shutdown The previous ubuntu-latest lint-and-test run was canceled during plugin contract verification (annotation: "The operation was canceled."). Lint had already passed; tests never started. Tree is unchanged. --------- Co-authored-by: HHXXYY123 <117068187+HHXXYY123@users.noreply.github.com>
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const test = require('node:test');
|
|
const { EventEmitter } = require('node:events');
|
|
const { createPreloadApi } = require('./api.cjs');
|
|
|
|
const channel = 'netcatty:system-theme-changed';
|
|
|
|
test('system theme subscription forwards light/dark without exposing the IPC event and unsubscribes', () => {
|
|
const ipcRenderer = new EventEmitter();
|
|
const api = createPreloadApi({ ipcRenderer, webUtils: {} });
|
|
const calls = [];
|
|
const unsubscribe = api.onSystemThemeChanged((...args) => calls.push(args));
|
|
ipcRenderer.emit(channel, { sender: 'private' }, { isDark: true });
|
|
ipcRenderer.emit(channel, { sender: 'private' }, { isDark: false });
|
|
assert.deepEqual(calls, [[{ isDark: true }], [{ isDark: false }]]);
|
|
unsubscribe();
|
|
ipcRenderer.emit(channel, {}, { isDark: true });
|
|
assert.equal(calls.length, 2);
|
|
assert.equal(ipcRenderer.listenerCount(channel), 0);
|
|
});
|
|
|
|
test('system theme subscription ignores malformed payloads', () => {
|
|
const ipcRenderer = new EventEmitter();
|
|
const api = createPreloadApi({ ipcRenderer, webUtils: {} });
|
|
const calls = [];
|
|
const unsubscribe = api.onSystemThemeChanged((payload) => calls.push(payload));
|
|
for (const payload of [undefined, null, {}, { isDark: 'false' }, { isDark: 0 }]) {
|
|
ipcRenderer.emit(channel, {}, payload);
|
|
}
|
|
unsubscribe();
|
|
assert.deepEqual(calls, []);
|
|
});
|