295 lines
25 KiB
JavaScript
295 lines
25 KiB
JavaScript
// Actual application CSS + generated WebRTC, exclusively in a disposable offscreen Electron window.
|
|
// No native focus/input, PiP/fullscreen, capture devices, clipboard, server or audible output.
|
|
import { launchApp, waitForAsync } from './lib/electron-app.mjs';
|
|
import { GENERATED_STREAM_COMMANDS, installGeneratedStreams, relayGeneratedStreamCommand, watchGeneratedStream } from './lib/generated-stream.mjs';
|
|
import { checkStreamExtras } from './lib/stream-extras-checks.mjs';
|
|
import { checkStreamPopout } from './lib/stream-popout-checks.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/stream-stage-offscreen');
|
|
mkdirSync(out, { recursive: true });
|
|
const profile = mkdtempSync(path.join(tmpdir(), 'teamspeach-stage-offscreen-'));
|
|
const result = { offscreenOnly: true, generatedWebRTC: true, nativeWindowEvidence: false, cases: [], checks: [], errors: [] };
|
|
let app;
|
|
function check(condition, label, evidence) {
|
|
result.checks.push({ label, passed: Boolean(condition), ...(evidence === undefined ? {} : { evidence }) });
|
|
}
|
|
try {
|
|
app = await launchApp({ profile, exe: option('exe') });
|
|
const page = await app.firstWindow();
|
|
page.on('pageerror', error => result.errors.push(error.message));
|
|
result.window = await app.evaluate(({ BrowserWindow }) => {
|
|
const win = BrowserWindow.getAllWindows()[0];
|
|
win.webContents.setAudioMuted(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 });
|
|
const cdp = await page.context().newCDPSession(page);
|
|
const move = (x, y) => cdp.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x, y });
|
|
const key = async (key, code = key, windowsVirtualKeyCode = 0) => {
|
|
await cdp.send('Input.dispatchKeyEvent', { type: 'keyDown', key, code, windowsVirtualKeyCode });
|
|
await cdp.send('Input.dispatchKeyEvent', { type: 'keyUp', key, code, windowsVirtualKeyCode });
|
|
};
|
|
const click = async selector => {
|
|
const r = await page.locator(selector).boundingBox();
|
|
assert.ok(r, `missing control ${selector}`);
|
|
const point = { x: r.x + r.width / 2, y: r.y + r.height / 2 };
|
|
await move(point.x, point.y);
|
|
await cdp.send('Input.dispatchMouseEvent', { type: 'mousePressed', ...point, button: 'left', clickCount: 1 });
|
|
await cdp.send('Input.dispatchMouseEvent', { type: 'mouseReleased', ...point, button: 'left', clickCount: 1 });
|
|
};
|
|
await page.waitForSelector('#view-onboarding', { state: 'visible' });
|
|
await page.evaluate(() => {
|
|
window.__captureRequests = 0; window.__nativeRequests = 0;
|
|
window.__captureStacks = [];
|
|
for (const method of ['getUserMedia', 'getDisplayMedia']) navigator.mediaDevices[method] = async () => { window.__captureRequests++; window.__captureStacks.push({ method, stack: new Error().stack, state: window.teamspeachDiagnostics?.snapshot() }); throw new Error('Capture forbidden in stage fixture'); };
|
|
navigator.mediaDevices.enumerateDevices = async () => [];
|
|
for (const [prototype, method] of [[Element.prototype, 'requestFullscreen'], [HTMLVideoElement.prototype, 'requestPictureInPicture']]) {
|
|
prototype[method] = async () => { window.__nativeRequests++; throw new Error('Native presentation forbidden in stage fixture'); };
|
|
}
|
|
Object.defineProperty(document, 'pictureInPictureEnabled', { configurable: true, value: false });
|
|
const input = document.querySelector('#onboarding-nick');
|
|
input.value = 'StageFixture'; input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
document.querySelector('#onboarding-submit').click();
|
|
});
|
|
await page.waitForSelector('#view-app', { state: 'visible' });
|
|
await page.waitForFunction(() => window.teamspeachDiagnostics?.snapshot().core === 'ready');
|
|
const muteResult = await page.evaluate(() => window.teamspeach.request('c1', 'set_audio', { input_muted: true, output_muted: true }));
|
|
assert.equal(muteResult.ok, true, 'disconnected real core must confirm mute before synthetic server events');
|
|
await page.evaluate(async () => {
|
|
const result = await window.teamspeach.setPrefs({ autoEnableMicrophone: false, autoReactivateMicOnPreviousTarget: false });
|
|
if (!result.ok) throw new Error('Unable to configure isolated listen-only fixture');
|
|
const { S, connectionById } = await import('./js/state.js');
|
|
S.prefs = result.prefs;
|
|
connectionById('c1').inputEnabled = false;
|
|
});
|
|
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].webContents.send('core:event', { connectionId: 'c1', event: 'audio_state', input_muted: true, output_muted: true, transmitting: false }));
|
|
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].webContents.send('core:event', { connectionId: 'c1', event: 'state', state: 'connected', address: 'fixture.invalid', reason: null }));
|
|
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].webContents.send('core:event', { ...{
|
|
event: 'snapshot', rev: 1, own_client_id: 1, own_channel_id: 20,
|
|
server: { name: 'Generated player QA — no server', uid: 'fixture-server=', version: '', welcome_message: '' }, server_groups: [], channel_groups: [],
|
|
channels: [{ id: 20, parent_id: 0, depth: 0, order: 0, name: 'Screens', topic: 'Generated media · isolated renderer', codec: 'opus_voice' }],
|
|
clients: [
|
|
{ id: 1, uid: 'self', nickname: 'StageFixture', channel_id: 20, is_self: true, client_type: 'normal', is_streaming: false },
|
|
{ id: 11, uid: 'mira', nickname: 'Mira', channel_id: 20, client_type: 'normal', is_streaming: false },
|
|
{ id: 12, uid: 'oleg', nickname: 'Oleg', channel_id: 20, client_type: 'normal', is_streaming: false },
|
|
],
|
|
}, connectionId: 'c1' }));
|
|
await page.evaluate(async () => {
|
|
const chat = await import('./js/chat.js');
|
|
for (const text of ['Mira joined Screens', 'Oleg joined Screens', 'Generated source ready — no physical screen capture', 'This chat stays usable while resizing the video']) chat.addSystem((await import('./js/state.js')).viewedConnection(), 'channel', () => text);
|
|
});
|
|
await installGeneratedStreams(page, [
|
|
['stage-mira', 11, 'Design review — shared workspace with a deliberately long descriptive title / Обзор рабочего пространства и длинное название', '#25495a'],
|
|
['stage-oleg', 12, 'Ranked match / Совместная игра', '#403665'],
|
|
]);
|
|
await app.evaluate(({ ipcMain, BrowserWindow }, { commands, relaySource }) => {
|
|
const relay = new Function(`return (${relaySource});`)();
|
|
ipcMain.removeHandler('core:request');
|
|
ipcMain.handle('core:request', async (_event, connectionId, command, args) => {
|
|
if (!commands.includes(command)) return { ok: false, error: { code: 'not_connected', message: 'Offscreen fixture, no server' } };
|
|
await BrowserWindow.getAllWindows()[0].webContents.executeJavaScript(relay(command, args, connectionId));
|
|
return { ok: true, result: {} };
|
|
});
|
|
}, { commands: GENERATED_STREAM_COMMANDS, relaySource: relayGeneratedStreamCommand.toString() });
|
|
const start = async id => {
|
|
await watchGeneratedStream(page, id);
|
|
const baseline = await cdp.send('Runtime.evaluate', { expression: `(() => {
|
|
const id = ${JSON.stringify(id)};
|
|
window.__identities ??= new Map(); const video = document.querySelector('section.stream-view[data-stream-id="' + id + '"] video');
|
|
if (!video?.srcObject) throw new Error('Decoded receiver has no attached media in the owning world');
|
|
window.__identities.set(id, { video, media: video.srcObject });
|
|
return { media: video.srcObject.id, tracks: video.srcObject.getTracks().map(track => track.id) };
|
|
})()`, returnByValue: true });
|
|
if (baseline.exceptionDetails) throw new Error(JSON.stringify(baseline.exceptionDetails));
|
|
};
|
|
const layout = () => page.evaluate(() => {
|
|
const rect = selector => document.querySelector(selector).getBoundingClientRect().toJSON();
|
|
const area = document.querySelector('#stream-area');
|
|
return {
|
|
area: { ...rect('#stream-area'), scrollWidth: area.scrollWidth, clientWidth: area.clientWidth, scrollHeight: area.scrollHeight, clientHeight: area.clientHeight }, chat: rect('.chat'), input: rect('#chat-input'),
|
|
bodyOverflow: document.documentElement.scrollWidth > innerWidth,
|
|
headingHeight: document.querySelector('.stream-stage-heading')?.getBoundingClientRect().height ?? 0,
|
|
grid: rect('#stream-grid'), pageCount: document.querySelectorAll('.stream-pagination button').length,
|
|
hiddenTiles: document.querySelectorAll('.stream-view[hidden]').length,
|
|
tiles: Array.from(document.querySelectorAll('.stream-view:not([hidden])'), tile => {
|
|
const video = tile.querySelector('video'), bar = tile.querySelector('.stream-bar'), controls = tile.querySelector('.stream-controls'), title = tile.querySelector('.stream-title');
|
|
const v = video.getBoundingClientRect(), t = tile.getBoundingClientRect();
|
|
const renderedWidth = Math.min(v.width, v.height * video.videoWidth / video.videoHeight);
|
|
const renderedHeight = renderedWidth * video.videoHeight / video.videoWidth;
|
|
const borderHeight = parseFloat(getComputedStyle(tile).borderTopWidth) + parseFloat(getComputedStyle(tile).borderBottomWidth);
|
|
return { id: tile.dataset.streamId, tile: t.toJSON(), video: v.toJSON(), borderHeight, renderedWidth, renderedHeight, fill: renderedWidth / v.width, imageAreaRatio: renderedWidth * renderedHeight / (v.width * v.height),
|
|
fit: getComputedStyle(video).objectFit, barPosition: getComputedStyle(bar).position, barInsideStage: bar.parentElement.classList.contains('stream-stage'),
|
|
controlsOpacity: Number(getComputedStyle(controls).opacity), title: title.textContent, titleWidth: title.clientWidth, titleScrollWidth: title.scrollWidth,
|
|
ellipsis: getComputedStyle(title).textOverflow, detailsOpen: tile.querySelector('details').open,
|
|
statsVisible: tile.querySelector('.stream-stats').checkVisibility(),
|
|
overlayPointerEvents: getComputedStyle(tile.querySelector('.stream-overlay')).pointerEvents,
|
|
pipDisabled: tile.querySelector('[data-role="stream-pip"]').disabled,
|
|
pipLabel: tile.querySelector('[data-role="stream-pip"]').getAttribute('aria-label'),
|
|
actions: Array.from(tile.querySelectorAll('button,summary,input'), node => ({ role: node.dataset.role, label: node.getAttribute('aria-label') || node.textContent.trim() })) };
|
|
}),
|
|
};
|
|
});
|
|
await start('stage-mira');
|
|
await page.evaluate(() => document.querySelector('#sidebar-splitter').focus({ preventScroll: true }));
|
|
await key('Home', 'Home', 36); // Official sidebar rail leaves the maximum available three-pane workspace.
|
|
await page.evaluate(() => document.querySelectorAll('#toasts button').forEach(button => button.click()));
|
|
const first = '[data-stream-id="stage-mira"]';
|
|
const configurations = ['en', 'ru'].flatMap(language => ['dark', 'light'].flatMap(theme =>
|
|
[[1280, 900], [880, 560]].map(([width, height]) => [width, height, language, theme])));
|
|
for (const count of [1, 2]) {
|
|
if (count === 2) await start('stage-oleg');
|
|
for (const [width, height, language, theme] of configurations) {
|
|
await app.evaluate(({ BrowserWindow }, size) => BrowserWindow.getAllWindows()[0].setContentSize(...size), [width, height]);
|
|
await page.evaluate(async ({ language, theme }) => {
|
|
const { setLanguage } = await import('./js/i18n.js'); setLanguage(language);
|
|
await window.teamspeach.setPrefs({ theme });
|
|
const { S } = await import('./js/state.js');
|
|
S.prefs.streamStageRatio = 0.55; S.prefs.streamStageCollapsed = false;
|
|
(await import('./js/watch.js')).applyWatchPrefs();
|
|
document.querySelector('#stream-area').scrollTop = 0;
|
|
document.activeElement?.blur();
|
|
}, { language, theme });
|
|
await move(5, 5); await page.waitForTimeout(220);
|
|
const idle = await layout();
|
|
const stem = `${count}-player-${language}-${theme}-${width}x${height}`;
|
|
await page.screenshot({ path: path.join(out, `${stem}-idle.png`) });
|
|
const r = idle.tiles[0].video; await move(r.x + r.width / 2, r.y + r.height / 2); await page.waitForTimeout(220);
|
|
const hover = await layout();
|
|
await page.screenshot({ path: path.join(out, `${stem}-hover.png`) });
|
|
result.cases.push({ count, width, height, language, theme, idle, hover });
|
|
check(!idle.bodyOverflow && idle.area.scrollWidth <= idle.area.clientWidth, `${stem}: no horizontal overflow`);
|
|
check(idle.chat.height >= 180 && idle.input.bottom <= height && idle.area.bottom <= idle.chat.top, `${stem}: usable chat boundary`);
|
|
check(idle.tiles.length > 0 && idle.tiles[0].video.top >= idle.grid.top - 2 && idle.tiles[0].video.bottom <= idle.grid.bottom + 2, `${stem}: video remains inside source-aspect grid`);
|
|
check(idle.hiddenTiles === 0 || idle.pageCount > 1, `${stem}: overflow tiles have explicit page navigation`);
|
|
for (const tile of idle.tiles) {
|
|
check(tile.barPosition === 'absolute' && tile.barInsideStage && Math.abs(tile.video.height + tile.borderHeight - tile.tile.height) <= 2, `${stem}/${tile.id}: video has no permanent footer`);
|
|
check(tile.controlsOpacity === 0 && !tile.statsVisible && !tile.detailsOpen, `${stem}/${tile.id}: minimal idle chrome`);
|
|
check(tile.fit === 'contain' && tile.overlayPointerEvents === 'none', `${stem}/${tile.id}: contain fit and nonblocking status`);
|
|
check(tile.pipDisabled && Boolean(tile.pipLabel), `${stem}/${tile.id}: unavailable PiP is named and disabled`);
|
|
check(tile.actions.every(action => action.label), `${stem}/${tile.id}: named controls`);
|
|
check(tile.fill >= 0.95 && tile.imageAreaRatio >= 0.9, `${stem}/${tile.id}: contained image fills its source-aspect tile`, { renderedWidth: tile.renderedWidth, renderedHeight: tile.renderedHeight, imageAreaRatio: tile.imageAreaRatio });
|
|
}
|
|
check(hover.tiles[0].controlsOpacity === 1, `${stem}: pointer hover reveals controls`);
|
|
if (count === 1) check(Math.abs(idle.tiles[0].renderedWidth - Math.min(idle.grid.width, idle.grid.height * 16 / 9)) <= 8, `${stem}: single source maximizes picture within available three-pane grid`, { grid: idle.grid, width: idle.tiles[0].renderedWidth });
|
|
if (count === 1 && height === 900) check(idle.area.scrollHeight <= idle.area.clientHeight, `${stem}: no unnecessary stage scrollbar`);
|
|
}
|
|
}
|
|
const bothBefore = await page.evaluate(() => window.teamspeachDiagnostics.snapshot().watches);
|
|
await page.waitForFunction(previous => window.teamspeachDiagnostics.snapshot().watches.every(now => {
|
|
const old = previous.find(item => item.id === now.id);
|
|
return now.framesDecoded > old.framesDecoded && now.inboundAudioPackets > old.inboundAudioPackets;
|
|
}), bothBefore, { timeout: 10000 });
|
|
const identityReply = await cdp.send('Runtime.evaluate', { expression: `JSON.stringify([...window.__identities].map(([id, original]) => {
|
|
const video = document.querySelector('section.stream-view[data-stream-id="' + id + '"] video');
|
|
return { id, sameVideo: video === original.video, sameMedia: video?.srcObject === original.media,
|
|
originalMediaId: original.media?.id, currentMediaId: video?.srcObject?.id,
|
|
oldTracks: original.media?.getTracks().map(track => track.id), currentTracks: video?.srcObject?.getTracks().map(track => track.id) };
|
|
}))`, returnByValue: true });
|
|
if (identityReply.exceptionDetails) throw new Error(JSON.stringify(identityReply.exceptionDetails));
|
|
const identities = JSON.parse(identityReply.result.value);
|
|
check(identities.every(item => item.sameVideo && item.sameMedia), 'both viewers preserve video/media identity while frames and audio packets advance', identities);
|
|
await checkStreamPopout({ app, page, check, screenshot: (name, target) => target.screenshot({ path: path.join(out, `${name}.png`) }) });
|
|
await checkStreamExtras({ app, page, check, screenshot: name => page.screenshot({ path: path.join(out, `${name}.png`) }) });
|
|
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].setContentSize(1600, 1000));
|
|
await page.waitForTimeout(100);
|
|
await page.evaluate(() => { const area = document.querySelector('#stream-area'); area.scrollTop = area.scrollHeight; });
|
|
const secondControl = page.locator('section.stream-view[data-stream-id="stage-oleg"] [data-role="stream-stop"]');
|
|
await secondControl.scrollIntoViewIfNeeded();
|
|
await secondControl.focus();
|
|
await page.waitForTimeout(150);
|
|
const secondStop = await secondControl.boundingBox();
|
|
await move(secondStop.x + secondStop.width / 2, secondStop.y + secondStop.height / 2);
|
|
check(await page.evaluate(({ x, y }) => document.elementFromPoint(x, y)?.closest('[data-role="stream-stop"]')?.closest('.stream-view')?.dataset.streamId === 'stage-oleg', { x: secondStop.x + secondStop.width / 2, y: secondStop.y + secondStop.height / 2 }), 'second viewer controls are reachable after layout and focus');
|
|
await page.screenshot({ path: path.join(out, 'two-player-narrow-scrolled-controls.png') });
|
|
await page.evaluate(() => { document.querySelector('#stream-area').scrollTop = 0; });
|
|
// Actual hidden-webContents Tab default action, not synthetic DOM KeyboardEvent traversal.
|
|
await move(5, 5);
|
|
await page.evaluate(selector => document.querySelector(`${selector} summary`).focus({ preventScroll: true }), first);
|
|
await key('Tab', 'Tab', 9); await page.waitForTimeout(220);
|
|
const focus = await page.evaluate(() => ({ role: document.activeElement.dataset.role, opacity: getComputedStyle(document.activeElement.closest('.stream-view').querySelector('.stream-controls')).opacity }));
|
|
check(focus.role === 'stream-mute' && focus.opacity === '1', 'Tab reaches mute and reveals keyboard controls', focus);
|
|
await page.screenshot({ path: path.join(out, 'two-player-keyboard-focus.png') });
|
|
await key('Tab', 'Tab', 9);
|
|
check(await page.evaluate(() => document.activeElement.dataset.role) === 'stream-volume', 'Tab reaches volume slider');
|
|
const volumeBefore = await page.evaluate(() => document.activeElement.value);
|
|
await key('ArrowLeft', 'ArrowLeft', 37);
|
|
check(await page.evaluate(() => Number(document.activeElement.value)) < Number(volumeBefore), 'keyboard slider dispatch changes value');
|
|
await page.evaluate(selector => { const range = document.querySelector(`${selector} [data-role="stream-volume"]`); range.value = '37'; range.dispatchEvent(new Event('input', { bubbles: true })); range.dispatchEvent(new Event('change', { bubbles: true })); }, first);
|
|
check(await page.evaluate(selector => document.querySelector(`${selector} video`).volume, first) === 0.37, 'slider input dispatch updates media volume');
|
|
await click(`${first} [data-role="stream-mute"]`);
|
|
check(await page.evaluate(selector => document.querySelector(`${selector} video`).muted, first), 'pointer mute dispatch reaches media');
|
|
await click(`${first} summary`);
|
|
check((await layout()).tiles[0].statsVisible, 'actual details summary exposes stats');
|
|
await page.screenshot({ path: path.join(out, 'two-player-details.png') });
|
|
await key('Escape', 'Escape', 27);
|
|
check(!(await layout()).tiles[0].detailsOpen, 'Escape closes details');
|
|
check((await layout()).tiles[0].ellipsis === 'ellipsis' && (await layout()).tiles[0].titleScrollWidth > (await layout()).tiles[0].titleWidth, 'long title ellipsizes');
|
|
// A real divider drag in hidden Chromium; no OS pointer or window focus.
|
|
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].setContentSize(1100, 900));
|
|
await page.evaluate(() => document.querySelector('[data-stream-id="stage-oleg"] [data-role="stream-stop"]').click());
|
|
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().watches.length === 1);
|
|
await page.evaluate(async () => {
|
|
const response = await window.teamspeach.setPrefs({ streamStageRatio: 0.4, streamStageCollapsed: false });
|
|
(await import('./js/state.js')).S.prefs = response.prefs;
|
|
(await import('./js/watch.js')).applyWatchPrefs();
|
|
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
});
|
|
await page.waitForTimeout(150);
|
|
const before = await layout();
|
|
const split = await page.locator('#stream-splitter').boundingBox();
|
|
const point = { x: split.x + split.width * 0.25, y: split.y + split.height / 2 };
|
|
await page.evaluate(() => {
|
|
window.__dragEvents = [];
|
|
for (const type of ['pointerdown', 'pointermove', 'pointerup', 'pointercancel', 'lostpointercapture']) document.querySelector('#stream-splitter').addEventListener(type, event => window.__dragEvents.push({ type, y: event.clientY, buttons: event.buttons }));
|
|
});
|
|
await move(point.x, point.y);
|
|
await cdp.send('Input.dispatchMouseEvent', { type: 'mousePressed', ...point, button: 'left', buttons: 1, clickCount: 1 });
|
|
await cdp.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: point.x, y: point.y + 95, button: 'left', buttons: 1 });
|
|
await cdp.send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y + 95, button: 'left', buttons: 0, clickCount: 1 });
|
|
await page.waitForTimeout(150);
|
|
const resized = await layout();
|
|
check(resized.grid.height > before.grid.height + 50 && resized.chat.height >= 180 && resized.tiles[0].fill >= 0.95, 'pointer resize grows available stage while source-aspect video and chat remain usable', { before, resized, events: await page.evaluate(() => window.__dragEvents) });
|
|
await move(5, 5); await page.evaluate(() => document.activeElement?.blur());
|
|
await page.screenshot({ path: path.join(out, 'one-player-resized-1100x900.png') });
|
|
await page.evaluate(() => document.querySelector('#stream-splitter').focus({ preventScroll: true }));
|
|
await key('ArrowUp', 'ArrowUp', 38);
|
|
check((await layout()).grid.height < resized.grid.height, 'keyboard divider shrinks available stage');
|
|
await key('Enter', 'Enter', 13);
|
|
await waitForAsync(page, async () => (await import('./js/state.js')).S.prefs.streamStageRatio === 0.55);
|
|
const frameBefore = await page.evaluate(() => window.teamspeachDiagnostics.snapshot().watches[0]);
|
|
await click('#stream-collapse');
|
|
check(await page.locator('#stream-grid').isHidden(), 'collapse hides stage');
|
|
const saved = await page.evaluate(async () => ({ ...(await import('./js/state.js')).S.prefs }));
|
|
check(saved.streamStageCollapsed === true && saved.streamStageRatio === 0.55, 'collapsed/reset preferences committed');
|
|
await page.evaluate(async () => (await import('./js/watch.js')).applyWatchPrefs());
|
|
check(await page.locator('#stream-grid').isHidden(), 'applying saved collapsed preference remains collapsed');
|
|
await click('#stream-collapse');
|
|
await page.waitForFunction(old => { const now = window.teamspeachDiagnostics.snapshot().watches[0]; return now.framesDecoded > old.framesDecoded && now.inboundAudioPackets > old.inboundAudioPackets; }, frameBefore, { timeout: 10000 });
|
|
result.media = await page.evaluate(() => ({ joins: window.__joins, leaves: window.__leaves, snapshots: window.teamspeachDiagnostics.snapshot().watches,
|
|
identities: [...window.__identities].map(([id, original]) => { const video = document.querySelector(`[data-stream-id="${id}"] video`); return { id, present: Boolean(video), sameVideo: video === original.video, sameMedia: video?.srcObject === original.media }; }) }));
|
|
check(result.media.joins === 3 && result.media.leaves.includes('stage-oleg') && result.media.identities[0].sameVideo && result.media.identities[0].sameMedia, 'resize/collapse/stop and second connection preserve surviving video and MediaStream identity', result.media);
|
|
check(result.media.snapshots[0].framesDecoded > frameBefore.framesDecoded && result.media.snapshots[0].inboundAudioPackets > frameBefore.inboundAudioPackets, 'surviving generated video and silent audio RTP keep advancing');
|
|
await click(`${first} [data-role="stream-stop"]`);
|
|
await page.waitForFunction(() => window.teamspeachDiagnostics.snapshot().watches.length === 0);
|
|
check(true, 'pointer stop ends final viewer');
|
|
result.captureRequests = await page.evaluate(() => window.__captureRequests);
|
|
result.nativeRequests = await page.evaluate(() => window.__nativeRequests);
|
|
result.captureStacks = await page.evaluate(() => window.__captureStacks);
|
|
check(result.captureRequests === 0 && result.nativeRequests === 0, 'zero capture and native presentation requests');
|
|
check(result.errors.length === 0, 'no renderer errors', result.errors);
|
|
result.ok = result.checks.every(item => item.passed);
|
|
if (!result.ok) process.exitCode = 1;
|
|
} catch (error) {
|
|
result.ok = false; result.failure = 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, cases: result.cases.map(({ count, width, height, language, theme }) => ({ count, width, height, language, theme })), checks: result.checks.filter(item => !item.passed), checkCount: result.checks.length }, null, 2));
|
|
}
|