// Whole-shell visual/accessibility matrix. Real renderer; labelled synthetic read-only core responses. // All windows are hidden/nonfocusable/offscreen through the shared guard. No server, OS input, // clipboard, native presentation, private capture, audible output, or normal profile is used. import { closeSettings, launchApp } from './lib/electron-app.mjs'; import assert from 'node:assert/strict'; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import path from 'node:path'; const args = process.argv.slice(2); const option = key => args.includes(`--${key}`) ? args[args.indexOf(`--${key}`) + 1] : undefined; const out = path.resolve(option('out') || 'smoke-out/official-shell'); const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-official-shell-qa-')); mkdirSync(out, { recursive: true }); const result = { scope: 'Real offscreen renderer with labelled synthetic read-only IPC. No live server/native window behavior/audio quality claim.', cases: [], checks: [], errors: [], screenshots: [] }; let app, page; const check = (name, passed, evidence) => result.checks.push({ name, passed: Boolean(passed), evidence }); const click = selector => page.locator(selector).click(); const close = async () => { await page.keyboard.press('Escape'); await page.keyboard.press('Escape'); }; const configurations = ['en', 'ru'].flatMap(language => ['dark', 'light'].flatMap(theme => [[1553, 998], [1280, 900], [880, 560]].map(([width, height]) => ({ language, theme, width, height })))); const configure = async config => { await app.evaluate(({ BrowserWindow }, size) => BrowserWindow.getAllWindows()[0].setContentSize(...size), [config.width, config.height]); await page.waitForFunction(size => innerWidth === size.width && innerHeight === size.height, config); await page.evaluate(async ({ language, theme }) => { (await import('./js/i18n.js')).setLanguage(language); await window.teamspeach.setPrefs({ theme }); }, config); await page.waitForFunction(dark => matchMedia('(prefers-color-scheme: dark)').matches === dark, config.theme === 'dark'); }; const inspect = async (surface, config, selector) => { await page.evaluate(() => document.querySelectorAll('#toasts button').forEach(button => button.click())); if (surface.startsWith('settings-')) await page.evaluate(() => { document.querySelector('.settings-scroll').scrollTop = 0; }); const evidence = await page.evaluate(selector => { const element = document.querySelector(selector); const rect = element.getBoundingClientRect(); const visible = node => node.checkVisibility() && node.getBoundingClientRect().width > 0; const controls = [...element.querySelectorAll('button,input,select,textarea,[role="menuitem"]')].filter(visible); const unnamed = controls.filter(node => !node.getAttribute('aria-label') && !node.getAttribute('aria-labelledby') && !node.labels?.length && !node.textContent.trim() && !node.title).map(node => node.id || node.className); const blur = [...document.querySelectorAll('*')].filter(visible).filter(node => !['none', ''].includes(getComputedStyle(node).backdropFilter)).map(node => ({ selector: node.id || node.className, filter: getComputedStyle(node).backdropFilter, width: node.clientWidth, height: node.clientHeight })); return { viewport: [innerWidth, innerHeight], document: [document.documentElement.scrollWidth, document.documentElement.scrollHeight], rect: rect.toJSON(), clientWidth: element.clientWidth, scrollWidth: element.scrollWidth, unnamed, blur }; }, selector); check(`${surface}/${config.language}/${config.theme}/${config.width}: viewport containment`, evidence.document[0] <= config.width && evidence.document[1] <= config.height && evidence.rect.left >= -1 && evidence.rect.right <= config.width + 1, evidence); check(`${surface}/${config.language}/${config.theme}/${config.width}: named controls`, evidence.unnamed.length === 0, evidence.unnamed); check(`${surface}/${config.language}/${config.theme}/${config.width}: blur limited to transient controls`, evidence.blur.every(item => /client-menu|device-menu|toast/.test(item.selector) && item.width < config.width && item.height < config.height), evidence.blur); const record = { surface, ...config, evidence }; // Four complementary pixel cases, all eight combinations measured. This is one bounded review batch. if (config.width === 1553 || (config.language === 'en') === (config.width === 1280)) { record.screenshot = `${surface}-${config.language}-${config.theme}-${config.width}x${config.height}.png`; await page.screenshot({ path: path.join(out, record.screenshot) }); result.screenshots.push(record.screenshot); } result.cases.push(record); }; const send = event => app.evaluate(({ BrowserWindow }, event) => BrowserWindow.getAllWindows()[0].webContents.send('core:event', { ...event, connectionId: 'c1' }), event); try { app = await launchApp({ exe: option('exe'), profile }); result.window = await app.evaluate(({ BrowserWindow, session }) => { const win = BrowserWindow.getAllWindows()[0]; win.webContents.setAudioMuted(true); session.defaultSession.setPermissionRequestHandler((_w, _p, done) => done(false)); session.defaultSession.setPermissionCheckHandler(() => false); session.defaultSession.webRequest.onBeforeRequest({ urls: ['http://*/*', 'https://*/*'] }, (_details, done) => done({ cancel: true })); return { visible: win.isVisible(), focusable: win.isFocusable(), offscreen: win.webContents.isOffscreen(), audioMuted: win.webContents.isAudioMuted() }; }); assert.deepEqual(result.window, { visible: false, focusable: false, offscreen: true, audioMuted: true }); page = await app.firstWindow(); page.on('pageerror', error => result.errors.push(error.message)); await page.waitForSelector('#view-onboarding', { state: 'visible' }); await page.evaluate(() => { window.__forbiddenCapture = 0; for (const key of ['getUserMedia', 'getDisplayMedia']) navigator.mediaDevices[key] = async () => { window.__forbiddenCapture++; throw new DOMException('Capture forbidden in whole-shell fixture', 'NotAllowedError'); }; navigator.mediaDevices.enumerateDevices = async () => []; Element.prototype.requestFullscreen = HTMLVideoElement.prototype.requestPictureInPicture = async () => { throw new Error('Native presentation forbidden'); }; }); for (const config of configurations) { await configure(config); await inspect('onboarding', config, '#view-onboarding'); } await page.fill('#onboarding-nick', 'ParityFixture'); await click('#onboarding-submit'); await page.waitForSelector('#view-app', { state: 'visible' }); await page.waitForFunction(() => window.teamspeachDiagnostics?.snapshot().core === 'ready'); await app.evaluate(({ ipcMain }) => { globalThis.__shellParityCommands = []; ipcMain.removeHandler('core:request'); const allowed = { allowed: true, reason: 'fixture', source: 'fixture' }; ipcMain.handle('core:request', (_event, connectionId, cmd, args) => { globalThis.__shellParityCommands.push({ cmd, args }); if (cmd === 'client_context') return { ok: true, result: { client_id: args.client_id, uid: args.uid, generation: 1, is_self: args.client_id === 1, capabilities: Object.fromEntries(['commander','avatar','poke','volume','connection_info','server_group','channel_group','client_permissions','channel_permissions','set_client_permission','set_channel_permission','kick_channel','kick_server','ban'].map(key => [key, allowed])), server_groups: [{ id: 7, name: 'Fixture operators / Операторы', member: false, can_add: allowed, can_remove: allowed }], channel_groups: [{ id: 9, name: 'Fixture voice / Голос', member: true, can_set: allowed }], permissions: [{ id: 101, name: 'fixture_permission', description: 'Read-only visual fixture / Проверка отображения' }], volume_db: 0, volume_muted: false } }; if (cmd === 'client_action' && args.action === 'connection_info') return { ok: true, result: { rows: [{ clid: args.client_id, connection_ping: '23.42', connection_ping_deviation: '1.75', connection_connected_time: '183845000', connection_client_ip: '2001:db8:abcd:1234:5678:90ab:cdef:1234', connection_client_port: '9987', connection_bytes_sent_total: '123456789012', connection_bytes_received_total: '234567890123', connection_bandwidth_sent_last_second_total: '123456', connection_bandwidth_received_last_second_total: '345678', connection_packetloss_total: '0.0125', connection_packets_sent_total: '12345678', fixture_long_value: 'Labelled synthetic read-only diagnostic value: ' + 'long-value-'.repeat(16) }] } }; if (cmd === 'client_action' && ['client_permissions','channel_permissions'].includes(args.action)) return { ok: true, result: { rows: [{ permid: 101, permname: 'fixture_permission', permvalue: 75, permnegated: 0, permskip: 0 }, { permid: 102, permname: 'fixture_long_permission_identifier_for_wrapping', permvalue: 100, permnegated: 0, permskip: 1 }] } }; if (cmd === 'stream_list') return { ok: true, result: { results: [] } }; if (cmd === 'set_transmit') return { ok: true, result: args }; return { ok: false, error: { code: 'not_connected', message: 'Read-only isolated visual fixture; command not dispatched' } }; }); }); await page.evaluate(async () => { const { S } = await import('./js/state.js'); const response = await window.teamspeach.setPrefs({ savedServers: [{ id: 'fixture1', name: 'Design friends / Друзья', address: 'fixture.invalid:9987' }, { id: 'fixture2', name: 'Long saved community server / Длинное имя сервера', address: 'long-community-name.example.invalid:9987' }] }); if (!response.ok) throw new Error('Fixture preferences were rejected'); S.prefs = response.prefs; (await import('./js/servers.js')).renderServers(); }); for (const config of configurations) { await configure(config); await inspect('connect', config, '#connect-view'); } await send({ event: 'audio_state', input_muted: true, output_muted: true, transmitting: false }); await send({ event: 'state', state: 'connected', address: 'fixture.invalid:9987', reason: null }); await send({ event: 'snapshot', rev: 1, own_client_id: 1, own_channel_id: 10, server: { name: 'Parity fixture / Сервер друзей', uid: 'fixture-server=', version: 'read-only fixture', welcome_message: '' }, server_groups: [], channel_groups: [], channels: [{ id: 10, parent_id: 0, order: 0, depth: 0, name: 'Design room / Общение', topic: 'A quiet shared space / Вместе за одним столом', codec: 'opus_voice', max_clients: -1 }, { id: 20, parent_id: 0, order: 10, depth: 0, name: 'Games / Совместная игра', codec: 'opus_voice', max_clients: 12 }], clients: [{ id: 1, uid: 'fixture-self', nickname: 'ParityFixture', is_self: true, channel_id: 10, input_muted: true, output_muted: true, input_hardware: true, server_groups: [] }, { id: 2, uid: 'fixture-mira', nickname: 'Mira / Мира', channel_id: 10, input_hardware: true, server_groups: [] }, { id: 3, uid: 'fixture-oleg', nickname: 'Oleg / Олег', channel_id: 20, input_hardware: true, server_groups: [] }] }); await send({ event: 'text', target: 'channel', from_client_id: 2, from_nickname: 'Mira / Мира', message: 'Read-only visual fixture — no server or private conversation. Проверяем читаемость сообщения и длинной ссылки: https://example.invalid/design-review/representative-long-link' }); const openMenu = async () => { await page.locator('.member-row[data-clid="2"] .row-btn').click({ button: 'right' }); await page.waitForSelector('.client-menu:not([aria-busy]) [data-action="connection_info"]'); }; for (const config of configurations) { await configure(config); if (await page.getAttribute('#servers-toggle', 'aria-expanded') !== 'true') await click('#servers-toggle'); await inspect('shell-chat', config, '#view-app'); await click('#btn-settings'); const panels = await page.locator('#settings-nav [data-panel]').evaluateAll(nodes => nodes.map(node => node.dataset.panel)); for (const panel of panels) { await click(`#settings-nav [data-panel="${panel}"]`); await inspect(`settings-${panel}`, config, `.settings-panel[data-panel="${panel}"]`); if (panel === 'video') { await page.locator('.settings-panel[data-panel="video"] details').evaluateAll(nodes => nodes.forEach(node => { node.open = true; })); await inspect('settings-video-details', config, '.settings-panel[data-panel="video"]'); } } await closeSettings(page); for (const control of ['mute', 'deafen']) { await page.locator(`#btn-${control}`).click({ button: 'right' }); await page.waitForSelector('.device-menu:not([aria-busy])'); await inspect(`device-${control}`, config, '.device-menu'); await close(); } await openMenu(); await inspect('client-menu', config, '.client-menu'); await close(); for (const action of ['volume','server_group','channel_group','connection_info','client_permissions','channel_permissions','poke','ban']) { await openMenu(); await click(`.client-menu:not(.client-submenu) [data-action="${action}"]`); const selector = ['volume','server_group','channel_group'].includes(action) ? '.client-menu-page' : action === 'connection_info' ? '.client-menu-info' : '.client-dialog'; await page.waitForSelector(selector); if (action === 'connection_info') await page.waitForSelector('.client-menu-info .connection-record'); else if (['client_permissions','channel_permissions'].includes(action)) await page.waitForFunction(() => !document.querySelector('.client-dialog [aria-busy="true"]') && document.querySelector('.client-info-table')); await inspect(action, config, selector); await close(); } } // Measured token contrast over opaque semantic surfaces; translucent pixel contrast is reviewed separately. for (const theme of ['dark','light']) { await configure({ language: 'en', theme, width: 1280, height: 900 }); const contrasts = await page.evaluate(() => { const style = getComputedStyle(document.documentElement); const canvas = document.createElement('canvas'); canvas.width = canvas.height = 1; const ctx = canvas.getContext('2d'); const rgb = value => { ctx.clearRect(0, 0, 1, 1); ctx.fillStyle = value; ctx.fillRect(0, 0, 1, 1); return [...ctx.getImageData(0, 0, 1, 1).data].slice(0, 3); }; const luminance = color => rgb(color).map(value => { const n = value / 255; return n <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4; }).reduce((sum, n, i) => sum + n * [0.2126, 0.7152, 0.0722][i], 0); return ['--tsv-font-color','--tsv-font-subtitle-color','--ts-third-font-color'].flatMap(text => ['--tsv-bg','--tsv-shaded-bg','--tsv-header-bg'].map(background => { const fg = style.getPropertyValue(text).trim(), bg = style.getPropertyValue(background).trim(); const a = luminance(fg), b = luminance(bg); return { text, background, fg, bg, ratio: (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05) }; })); }); result.contrasts ??= []; result.contrasts.push({ theme, pairs: contrasts }); for (const pair of contrasts) { check(`${theme}: official contrast tokens resolve ${pair.text}/${pair.background}`, Boolean(pair.fg && pair.bg), pair); if (pair.text === '--tsv-font-color') check(`${theme}: primary text contrast ${pair.background}`, pair.ratio >= 4.5, pair); } } await page.emulateMedia({ reducedMotion: 'reduce' }); const motion = await page.evaluate(() => [...document.querySelectorAll('*')].filter(node => node.checkVisibility()).map(node => ({ selector: node.id || node.className, animation: getComputedStyle(node).animationDuration, transition: getComputedStyle(node).transitionDuration })).filter(item => [...item.animation.split(','), ...item.transition.split(',')].some(value => parseFloat(value) > 0))); check('Reduced motion removes active animation/transition duration', motion.length === 0, motion); const cdp = await page.context().newCDPSession(page); await cdp.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-reduced-transparency', value: 'reduce' }, { name: 'prefers-reduced-motion', value: 'reduce' }] }); await openMenu(); const transparency = await page.evaluate(() => ({ reduced: matchMedia('(prefers-reduced-transparency: reduce)').matches, backdrop: getComputedStyle(document.querySelector('.client-menu')).backdropFilter })); check('Reduced transparency removes menu backdrop blur', transparency.reduced && transparency.backdrop === 'none', transparency); await page.screenshot({ path: path.join(out, 'reduced-transparency-menu.png') }); result.screenshots.push('reduced-transparency-menu.png'); await close(); await cdp.send('Emulation.setEmulatedMedia', { features: [] }); await cdp.detach(); await page.emulateMedia({ forcedColors: 'active', reducedMotion: 'reduce' }); await page.focus('#btn-settings'); await page.keyboard.press('Tab'); const focus = await page.evaluate(() => ({ forced: matchMedia('(forced-colors: active)').matches, selector: document.activeElement.id, outline: getComputedStyle(document.activeElement).outlineStyle, width: getComputedStyle(document.activeElement).outlineWidth })); check('Forced colors retains keyboard focus indicator', focus.forced && focus.outline !== 'none' && parseFloat(focus.width) > 0, focus); await page.screenshot({ path: path.join(out, 'forced-colors-focus.png') }); result.screenshots.push('forced-colors-focus.png'); result.commands = await app.evaluate(() => globalThis.__shellParityCommands); check('No connect or mutation requested', !result.commands.some(({ cmd, args }) => cmd === 'connect' || cmd === 'voice_send' || cmd === 'client_action' && !['connection_info','client_permissions','channel_permissions'].includes(args.action))); result.captureRequests = await page.evaluate(() => window.__forbiddenCapture); check('No physical capture attempted', result.captureRequests === 0, result.captureRequests); result.ok = result.errors.length === 0 && result.checks.every(item => item.passed); } catch (error) { result.ok = false; result.errors.push(error.stack || String(error)); if (page) await page.screenshot({ path: path.join(out, 'failure.png') }).catch(() => {}); } finally { if (app) await app.close().catch(() => {}); rmSync(profile, { recursive: true, force: true }); writeFileSync(path.join(out, 'result.json'), JSON.stringify(result, null, 2)); } console.log(JSON.stringify({ ok: result.ok, out, cases: result.cases.length, checks: result.checks.length, failures: result.checks.filter(item => !item.passed), errors: result.errors }, null, 2)); process.exitCode = result.ok ? 0 : 1;