Preserve accumulated client implementation since v0.1.4, including local identities, multi-server state, chat, administration, audio and streaming controls. Refine official-source layout, original artwork, responsive composer overflow, settings navigation and chat scroll anchoring. Current verification: Node suite passes; isolated packaged chat and responsive control smokes pass without device capture. Native core is reused, not rebuilt in this pass. Strict whole-screen visual parity remains incomplete; no 1:1 or cross-platform acceptance claim. Local checkpoint only; no release or push.
110 lines
7.9 KiB
JavaScript
110 lines
7.9 KiB
JavaScript
// Hidden/offscreen titlebar evidence only. Never sends OS keys, opens native dialogs,
|
|
// captures the desktop, plays audio, requests fullscreen/PiP or shows a test window.
|
|
import { launchApp, root } from './lib/electron-app.mjs';
|
|
import { createRequire } from 'node:module';
|
|
import assert from 'node:assert/strict';
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import path from 'node:path';
|
|
// The renderer bar must match the native caption overlay exactly (height and fill), as one official window bar.
|
|
const { TITLEBAR_HEIGHT, overlayColors } = createRequire(import.meta.url)(path.join(root, 'app/main/titlebar.js'));
|
|
const rgb = hex => `rgb(${hex.slice(1).match(/../g).map(h => parseInt(h, 16)).join(', ')})`;
|
|
const args = process.argv.slice(2);
|
|
const opt = (name, fallback) => args.includes(`--${name}`) ? args[args.indexOf(`--${name}`) + 1] : fallback;
|
|
const out = path.resolve(opt('out', 'smoke-out/titlebar'));
|
|
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-titlebar-'));
|
|
mkdirSync(out, { recursive: true });
|
|
const result = { scope: 'Disposable hidden offscreen Electron renderer and native theme/state reads. Native caption buttons are OS-owned and excluded from renderer screenshots. No desktop input, drag, Snap, Alt-F4, native maximize/minimize/fullscreen/PiP or cross-platform runtime claim.', checks: [], screenshots: [], errors: [] };
|
|
let app;
|
|
try {
|
|
app = await launchApp({ exe: opt('exe'), profile });
|
|
const page = await app.firstWindow();
|
|
page.on('pageerror', error => result.errors.push(error.message));
|
|
const safety = await app.evaluate(({ BrowserWindow }) => {
|
|
const win = BrowserWindow.getAllWindows()[0];
|
|
if (win.isVisible() || win.isFocused() || win.isFocusable() || !win.webContents.isOffscreen()) throw new Error('Titlebar smoke requires an invisible, unfocusable offscreen owned window');
|
|
// Native maximize/minimize can surface a hidden window on some platforms: refuse them.
|
|
for (const method of ['show', 'showInactive', 'focus', 'maximize', 'minimize', 'restore', 'setFullScreen', 'setSimpleFullScreen']) win[method] = () => { throw new Error(`Unsafe smoke window operation: ${method}`); };
|
|
return { visible: win.isVisible(), focused: win.isFocused(), focusable: win.isFocusable(), offscreen: win.webContents.isOffscreen() };
|
|
});
|
|
result.checks.push({ safety });
|
|
await page.waitForSelector('#view-onboarding', { state: 'visible', timeout: 30000 });
|
|
await page.evaluate(() => {
|
|
for (const method of ['getUserMedia', 'getDisplayMedia']) navigator.mediaDevices[method] = async () => { throw new Error('Physical capture forbidden in titlebar smoke'); };
|
|
});
|
|
await page.fill('#onboarding-nick', 'Titlebar QA');
|
|
await page.click('#onboarding-submit');
|
|
await page.waitForSelector('#view-app', { state: 'visible' });
|
|
const readGeometry = () => page.evaluate(() => {
|
|
const box = selector => { const r = document.querySelector(selector).getBoundingClientRect(); return { x: r.x, y: r.y, width: r.width, height: r.height, bottom: r.bottom }; };
|
|
const style = selector => getComputedStyle(document.querySelector(selector));
|
|
return { viewport: { width: innerWidth, height: innerHeight }, bar: box('.detail-pane-bar'), shell: box('#view-app'), sidebar: box('#app-sidebar'), workspace: box('.workspace'), drag: style('.detail-pane-bar').webkitAppRegion, controls: style('.central-toolbar').webkitAppRegion, background: style('.detail-pane-bar').backgroundColor, backgroundImage: style('.detail-pane-bar').backgroundImage, border: style('.detail-pane-bar').borderBottomWidth, shadow: style('.detail-pane-bar').boxShadow, label: document.querySelector('#window-titlebar').getAttribute('aria-label'), horizontalOverflow: document.documentElement.scrollWidth > innerWidth };
|
|
});
|
|
for (const [width, height] of [[1280, 900], [880, 560]]) {
|
|
await app.evaluate(({ BrowserWindow }, size) => BrowserWindow.getAllWindows()[0].setContentSize(...size), [width, height]);
|
|
for (const language of ['en', 'ru']) {
|
|
await page.evaluate(async language => { const i18n = await import('./js/i18n.js'); i18n.setLanguage(language); }, language);
|
|
for (const theme of ['dark', 'light']) {
|
|
await page.evaluate(theme => window.teamspeach.setPrefs({ theme }), theme);
|
|
await page.waitForFunction(dark => matchMedia('(prefers-color-scheme: dark)').matches === dark, theme === 'dark');
|
|
const geometry = await readGeometry();
|
|
assert.equal(geometry.bar.height, TITLEBAR_HEIGHT);
|
|
assert.equal(geometry.shell.y, 0, 'official pane bars are part of the shell, not an extra caption row');
|
|
assert.equal(geometry.shell.bottom, height);
|
|
assert.ok(geometry.sidebar.y === 0 && geometry.sidebar.bottom <= height, 'sidebar owns its native drag header inside viewport');
|
|
assert.ok(geometry.workspace.y === 0 && geometry.workspace.bottom <= height, 'workspace owns its 44px native caption header');
|
|
assert.equal(geometry.drag, 'drag');
|
|
assert.equal(geometry.controls, 'no-drag');
|
|
assert.equal(geometry.backgroundImage, 'none');
|
|
assert.equal(geometry.background, rgb(overlayColors(theme === 'dark').color), 'renderer bar fill equals native overlay fill');
|
|
assert.equal(geometry.shadow, 'none');
|
|
assert.equal(geometry.border, '0px', 'official window bar meets the pane header without a divider (official capture)');
|
|
assert.equal(geometry.horizontalOverflow, false);
|
|
assert.equal(geometry.label, language === 'ru' ? 'Заголовок окна' : 'Window title bar');
|
|
const file = `titlebar-${width}x${height}-${language}-${theme}.png`;
|
|
await page.screenshot({ path: path.join(out, file) });
|
|
result.screenshots.push(file);
|
|
result.checks.push({ language, theme, geometry });
|
|
}
|
|
}
|
|
}
|
|
await page.click('#btn-settings');
|
|
const settingsGeometry = await readGeometry();
|
|
assert.equal(settingsGeometry.shell.y, 0);
|
|
assert.equal(settingsGeometry.shell.bottom, 560);
|
|
result.checks.push({ settingsGeometry });
|
|
// Measure every outer view independently; these are layout fixtures, not core failure claims.
|
|
const viewGeometry = await page.evaluate(() => {
|
|
const views = [...document.querySelectorAll('#boot, #view-fatal, #view-onboarding, #view-app')];
|
|
const original = views.map(view => view.hidden);
|
|
const rows = views.map(view => {
|
|
for (const other of views) other.hidden = other !== view;
|
|
const r = view.getBoundingClientRect();
|
|
return { id: view.id, y: r.y, bottom: r.bottom };
|
|
});
|
|
views.forEach((view, index) => { view.hidden = original[index]; });
|
|
return rows;
|
|
});
|
|
for (const view of viewGeometry) { assert.equal(view.y, view.id === 'view-app' ? 0 : TITLEBAR_HEIGHT, view.id); assert.equal(view.bottom, 560, view.id); }
|
|
result.checks.push({ viewGeometry });
|
|
await page.evaluate(() => window.teamspeach.setPrefs({ theme: 'system' }));
|
|
const nativeDark = await app.evaluate(({ nativeTheme }) => ({ source: nativeTheme.themeSource, dark: nativeTheme.shouldUseDarkColors }));
|
|
await page.waitForFunction(dark => matchMedia('(prefers-color-scheme: dark)').matches === dark, nativeDark.dark);
|
|
assert.equal(nativeDark.source, 'system');
|
|
result.checks.push({ systemTheme: nativeDark, state: await page.evaluate(() => window.teamspeach.getWindowState()) });
|
|
const finalSafety = await app.evaluate(({ BrowserWindow }) => ({ visible: BrowserWindow.getAllWindows()[0].isVisible(), focused: BrowserWindow.getAllWindows()[0].isFocused() }));
|
|
assert.deepEqual(finalSafety, { visible: false, focused: false });
|
|
assert.deepEqual(result.errors, []);
|
|
result.checks.push({ finalSafety });
|
|
result.ok = true;
|
|
} catch (error) {
|
|
result.ok = false;
|
|
result.error = error.stack;
|
|
process.exitCode = 1;
|
|
} finally {
|
|
if (app) await app.close();
|
|
rmSync(profile, { recursive: true, force: true });
|
|
writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2));
|
|
console.log(JSON.stringify(result, null, 2));
|
|
}
|