Device menus: loading shell, stale enumeration dropped; strict origin parsing; no automatic silence warning; core transmit state at debug
ci / linux-arm64-cross (push) Successful in 1m51s
ci / linux-x64 (push) Failing after 5m39s

This commit is contained in:
omar committed 2026-10-24 06:09:48 +03:00
1 parent 401c331aa4
commit 41e90fb5e8
14 files changed
+164 -87

No files matched your search

+2 -1
View File
@@ -11,7 +11,8 @@
device menu sharing the Settings selection; left click still mutes/deafens. device menu sharing the Settings selection; left click still mutes/deafens.
- Voice diagnostics: the local log records the capture device and track state; with - Voice diagnostics: the local log records the capture device and track state; with
`TEAMSPEACH_LOG=debug` it also records push-to-talk presses with window focus and each transmission burst `TEAMSPEACH_LOG=debug` it also records push-to-talk presses with window focus and each transmission burst
(frames, peak level). A warning appears when two seconds of transmitted audio are silent. The push-to-talk hint says when the window is not focused (the key is read only there). (frames, peak level).
- The push-to-talk hint says when the window is not focused (the key is read only there).
- Fixed: ~1/256 newly created or imported identities could not be loaded again (private key with a leading - Fixed: ~1/256 newly created or imported identities could not be loaded again (private key with a leading
zero byte). Storage format unchanged. zero byte). Storage format unchanged.
+12 -7
View File
@@ -7,14 +7,19 @@
* Camera, screen capture and every other permission stay denied. * Camera, screen capture and every other permission stay denied.
*/ */
// WHATWG URL reports "null" as the origin of non-special schemes such as app:, so scheme and host are // WHATWG URL reports "null" as the origin of non-special schemes such as app:, so the origin is rebuilt from
// taken from the URL text directly. // the parsed protocol and host. Inputs with credentials or backslashes (lookalikes such as
const ORIGIN_RE = /^([a-z][a-z0-9+.-]*):\/\/([^/?#\\]*)/i; // "app://teamspeach\@evil" or "app://teamspeach@evil") never match.
function normalizeOrigin(origin) { function normalizeOrigin(origin) {
if (typeof origin !== 'string') return ''; if (typeof origin !== 'string' || origin.includes('\\')) return '';
const m = ORIGIN_RE.exec(origin); let url;
return m ? `${m[1]}://${m[2]}`.toLowerCase() : ''; try {
url = new URL(origin);
} catch {
return '';
}
if (url.username || url.password || !url.host) return '';
return `${url.protocol}//${url.host}`.toLowerCase();
} }
function isAppOrigin(origin, appOrigin) { function isAppOrigin(origin, appOrigin) {
+3
View File
@@ -374,7 +374,10 @@ function onCoreEvent(evt) {
break; break;
case 'audio_state': { case 'audio_state': {
const wasDeaf = S.audio.output_muted; const wasDeaf = S.audio.output_muted;
const wasTransmitting = S.audio.transmitting;
S.audio = { input_muted: Boolean(evt.input_muted), output_muted: Boolean(evt.output_muted), transmitting: Boolean(evt.transmitting) }; S.audio = { input_muted: Boolean(evt.input_muted), output_muted: Boolean(evt.output_muted), transmitting: Boolean(evt.transmitting) };
// Core-side confirmation that voice is going out (TEAMSPEACH_LOG=debug only).
if (S.audio.transmitting !== wasTransmitting) log('debug', `voice: core transmitting=${S.audio.transmitting}`);
if (S.audio.output_muted && !wasDeaf) voice.onOutputMuted(true); if (S.audio.output_muted && !wasDeaf) voice.onOutputMuted(true);
watch.applyVolume(); watch.applyVolume();
renderSelf(); renderSelf();
+64 -48
View File
@@ -38,14 +38,60 @@ function close({ restoreFocus = true } = {}) {
if (restoreFocus) anchor.focus(); if (restoreFocus) anchor.focus();
} }
async function show(anchor, kind, point) { let generation = 0;
/**
* The menu element exists from the first moment (with a loading line), so every close path — Escape,
* outside click, window blur, another menu — applies while device enumeration is still pending. The
* enumeration result only fills the menu that is still open for this request; a stale result is dropped.
*/
function show(anchor, kind, point) {
close({ restoreFocus: false }); close({ restoreFocus: false });
const choices = await voice.deviceChoices(); const gen = ++generation;
if (!choices) return; const title = kind === 'input' ? 'Микрофон' : 'Устройство вывода';
const body = h('div', { class: 'menu-body' }, h('p', { class: 'menu-note', text: 'Получаем список устройств…' }));
const menu = h('div', { class: 'device-menu', role: 'menu', 'aria-label': title, 'aria-busy': 'true', tabindex: '-1' },
h('div', { class: 'menu-title', text: title }),
body);
document.body.appendChild(menu);
anchor.setAttribute('aria-expanded', 'true');
position(menu, anchor, point);
let focusables = [];
const focusAt = (i) => focusables.length && focusables[(i + focusables.length) % focusables.length].focus();
const onKey = (e) => {
const i = focusables.indexOf(document.activeElement);
if (e.key === 'ArrowDown') { e.preventDefault(); focusAt(i + 1); }
else if (e.key === 'ArrowUp') { e.preventDefault(); focusAt(i - 1); }
else if (e.key === 'Home') { e.preventDefault(); focusAt(0); }
else if (e.key === 'End') { e.preventDefault(); focusAt(focusables.length - 1); }
else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(); }
else if (e.key === 'Tab') { close({ restoreFocus: false }); }
};
const onPointer = (e) => {
if (!menu.contains(e.target) && e.target !== anchor) close({ restoreFocus: false });
};
const onDismiss = () => close({ restoreFocus: false });
menu.addEventListener('keydown', onKey);
document.addEventListener('pointerdown', onPointer, true);
window.addEventListener('resize', onDismiss);
window.addEventListener('blur', onDismiss);
open = {
gen,
menu,
anchor,
cleanup: () => {
document.removeEventListener('pointerdown', onPointer, true);
window.removeEventListener('resize', onDismiss);
window.removeEventListener('blur', onDismiss);
},
};
menu.focus();
voice.deviceChoices().then((choices) => {
if (!open || open.gen !== gen || !choices) return; // closed or replaced meanwhile
const data = kind === 'input' ? choices.input : choices.output; const data = kind === 'input' ? choices.input : choices.output;
const selected = (kind === 'input' ? S.prefs.inputDeviceId : S.prefs.outputDeviceId) || ''; const selected = (kind === 'input' ? S.prefs.inputDeviceId : S.prefs.outputDeviceId) || '';
const title = kind === 'input' ? 'Микрофон' : 'Устройство вывода';
const items = data.options.map((o) => { const items = data.options.map((o) => {
const item = h('button', { const item = h('button', {
class: 'menu-item', class: 'menu-item',
@@ -67,18 +113,20 @@ async function show(anchor, kind, point) {
close({ restoreFocus: false }); close({ restoreFocus: false });
hooks.openAudioSettings(); hooks.openAudioSettings();
}); });
const note = data.redacted || data.physical === 0
? h('p', { class: 'menu-note', text: data.redacted ? 'Движок скрыл список устройств: доступно только системное устройство.' : kind === 'input' ? 'Микрофоны не найдены.' : 'Устройства вывода не найдены.' })
: null;
body.replaceChildren(...items, ...(note ? [note] : []), h('div', { class: 'menu-sep', role: 'separator' }), settingsItem);
menu.removeAttribute('aria-busy');
position(menu, anchor, point);
focusables = [...items, settingsItem];
// Move focus into the list only if it is still inside the menu (the user may have clicked elsewhere).
if (menu.contains(document.activeElement)) focusAt(Math.max(0, items.findIndex((i) => i.getAttribute('aria-checked') === 'true')));
});
}
const note = data.redacted || data.physical === 0 ? h('p', { class: 'menu-note', text: data.redacted ? 'Движок скрыл список устройств: доступно только системное устройство.' : kind === 'input' ? 'Микрофоны не найдены.' : 'Устройства вывода не найдены.' }) : null; /** Above the button (the footer sits at the bottom), clamped inside the viewport. */
const menu = h('div', { class: 'device-menu', role: 'menu', 'aria-label': title }, function position(menu, anchor, point) {
h('div', { class: 'menu-title', text: title }),
...items,
note,
h('div', { class: 'menu-sep', role: 'separator' }),
settingsItem);
document.body.appendChild(menu);
anchor.setAttribute('aria-expanded', 'true');
// Anchor above the button (the footer sits at the bottom), clamped inside the viewport.
const rect = anchor.getBoundingClientRect(); const rect = anchor.getBoundingClientRect();
const mw = menu.offsetWidth; const mw = menu.offsetWidth;
const mh = menu.offsetHeight; const mh = menu.offsetHeight;
@@ -90,36 +138,4 @@ async function show(anchor, kind, point) {
top = Math.max(margin, top); top = Math.max(margin, top);
menu.style.left = `${Math.round(left)}px`; menu.style.left = `${Math.round(left)}px`;
menu.style.top = `${Math.round(top)}px`; menu.style.top = `${Math.round(top)}px`;
const focusables = [...items, settingsItem];
const focusAt = (i) => focusables[(i + focusables.length) % focusables.length].focus();
const current = Math.max(0, items.findIndex((i) => i.getAttribute('aria-checked') === 'true'));
focusAt(current);
const onKey = (e) => {
const i = focusables.indexOf(document.activeElement);
if (e.key === 'ArrowDown') { e.preventDefault(); focusAt(i + 1); }
else if (e.key === 'ArrowUp') { e.preventDefault(); focusAt(i - 1); }
else if (e.key === 'Home') { e.preventDefault(); focusAt(0); }
else if (e.key === 'End') { e.preventDefault(); focusAt(focusables.length - 1); }
else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(); }
else if (e.key === 'Tab') { close({ restoreFocus: false }); }
};
const onPointer = (e) => {
if (!menu.contains(e.target) && e.target !== anchor) close({ restoreFocus: false });
};
const onResize = () => close({ restoreFocus: false });
menu.addEventListener('keydown', onKey);
document.addEventListener('pointerdown', onPointer, true);
window.addEventListener('resize', onResize);
window.addEventListener('blur', onResize);
open = {
menu,
anchor,
cleanup: () => {
document.removeEventListener('pointerdown', onPointer, true);
window.removeEventListener('resize', onResize);
window.removeEventListener('blur', onResize);
},
};
} }
+1 -9
View File
@@ -86,8 +86,6 @@ export function shouldTransmit() {
&& channelCanTransmit(); && channelCanTransmit();
} }
const SILENCE = 0.0005; // about -66 dBFS
function onFrame(pcm, rms, peak) { function onFrame(pcm, rms, peak) {
voiceStats.level = peak; voiceStats.level = peak;
if (micTest && !meterRaf) meterRaf = requestAnimationFrame(drawMeter); if (micTest && !meterRaf) meterRaf = requestAnimationFrame(drawMeter);
@@ -97,18 +95,12 @@ function onFrame(pcm, rms, peak) {
if (!sending) { if (!sending) {
sending = true; sending = true;
voiceStats.bursts += 1; voiceStats.bursts += 1;
burst = { frames: 0, peakMax: 0, warned: false, mode: S.prefs.transmitMode }; burst = { frames: 0, peakMax: 0, mode: S.prefs.transmitMode };
log('debug', `voice: burst start mode=${burst.mode} focused=${document.hasFocus()} capture=${engine.capturing}`); log('debug', `voice: burst start mode=${burst.mode} focused=${document.hasFocus()} capture=${engine.capturing}`);
hooks.onTransmitChanged(); hooks.onTransmitChanged();
} }
burst.frames += 1; burst.frames += 1;
if (peak > burst.peakMax) burst.peakMax = peak; if (peak > burst.peakMax) burst.peakMax = peak;
// Two seconds of near-digital silence usually means the wrong input device or a muted interface channel.
if (burst.frames === 100 && burst.peakMax < SILENCE && !burst.warned) {
burst.warned = true;
log('warn', 'voice: transmitting silence for 2 s (peak below -66 dBFS)');
toast('Микрофон передаёт тишину. Проверьте устройство и уровень в «Настройки → Звук» («Проверить микрофон»).', 'error');
}
} else if (sending) { } else if (sending) {
tp.endAudio(); tp.endAudio();
sending = false; sending = false;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 60 KiB

@@ -4,6 +4,8 @@
"name": "mic right-click", "name": "mic right-click",
"menu": true, "menu": true,
"inputMuted": false, "inputMuted": false,
"capturing": false,
"framesSent": 0,
"items": [ "items": [
{ {
"label": "Системное по умолчанию (Mic/Line/Inst 1-2 (MiniFuse 4))", "label": "Системное по умолчанию (Mic/Line/Inst 1-2 (MiniFuse 4))",
@@ -68,6 +70,18 @@
"name": "left click still toggles mute", "name": "left click still toggles mute",
"inputMuted": true "inputMuted": true
}, },
{
"name": "rapid mic → headphones while enumeration pending",
"menus": 1,
"label": "Устройство вывода",
"items": 7
},
{
"name": "dismissed before enumeration finished",
"menus": 0,
"focused": "connect-address",
"expanded": "false"
},
{ {
"name": "after restart", "name": "after restart",
"checkedIn": "Headset Microphone (Oculus Virtual Audio Device)", "checkedIn": "Headset Microphone (Oculus Virtual Audio Device)",
@@ -24,14 +24,16 @@
], ],
"status": "Найдено микрофонов: 6, устройств вывода: 6.", "status": "Найдено микрофонов: 6, устройств вывода: 6.",
"conn": "disconnected", "conn": "disconnected",
"framesSent": 0 "framesSent": 0,
"capturing": false
}, },
{ {
"name": "selected", "name": "selected",
"inputChoice": "Headset Microphone (Oculus Virtual Audio Device)", "inputChoice": "Headset Microphone (Oculus Virtual Audio Device)",
"outputChoice": "Realtek Digital Output (Realtek(R) Audio)", "outputChoice": "Realtek Digital Output (Realtek(R) Audio)",
"toasts": [], "toasts": [],
"framesSent": 0 "framesSent": 0,
"capturing": false
}, },
{ {
"name": "after restart", "name": "after restart",
+35 -5
View File
@@ -52,7 +52,7 @@ try {
await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 }); await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 });
await page.click('#btn-mute', { button: 'right' }); await page.click('#btn-mute', { button: 'right' });
await page.waitForSelector('.device-menu'); await page.waitForSelector('.device-menu [role="menuitemradio"]');
let s = await state(page); let s = await state(page);
step('mic right-click', { menu: s.menu, inputMuted: s.audio.input_muted, capturing: s.capturing, framesSent: s.framesSent, items: s.items, insideViewport: s.inside, focused: s.focused }); step('mic right-click', { menu: s.menu, inputMuted: s.audio.input_muted, capturing: s.capturing, framesSent: s.framesSent, items: s.items, insideViewport: s.inside, focused: s.focused });
if (s.audio.input_muted) throw new Error('right-click toggled mute'); if (s.audio.input_muted) throw new Error('right-click toggled mute');
@@ -70,7 +70,7 @@ try {
// Keyboard: Shift+F10 on the headphones button, arrows, Escape restores focus; deafen untouched. // Keyboard: Shift+F10 on the headphones button, arrows, Escape restores focus; deafen untouched.
await page.focus('#btn-deafen'); await page.focus('#btn-deafen');
await page.keyboard.press('Shift+F10'); await page.keyboard.press('Shift+F10');
await page.waitForSelector('.device-menu'); await page.waitForSelector('.device-menu [role="menuitemradio"]');
await page.keyboard.press('ArrowDown'); await page.keyboard.press('ArrowDown');
s = await state(page); s = await state(page);
step('headphones Shift+F10', { menu: s.menu, outputMuted: s.audio.output_muted, items: s.items.map((i) => i.label), insideViewport: s.inside }); step('headphones Shift+F10', { menu: s.menu, outputMuted: s.audio.output_muted, items: s.items.map((i) => i.label), insideViewport: s.inside });
@@ -80,10 +80,11 @@ try {
step('escape', { menuClosed: !s.menu, focusRestored: s.focused === 'btn-deafen', outputMuted: s.audio.output_muted }); step('escape', { menuClosed: !s.menu, focusRestored: s.focused === 'btn-deafen', outputMuted: s.audio.output_muted });
if (s.menu || s.focused !== 'btn-deafen' || s.audio.output_muted) throw new Error('escape/focus/deafen behaviour wrong'); if (s.menu || s.focused !== 'btn-deafen' || s.audio.output_muted) throw new Error('escape/focus/deafen behaviour wrong');
await page.click('#btn-deafen', { button: 'right' }); await page.click('#btn-deafen', { button: 'right' });
await page.waitForSelector('.device-menu'); await page.waitForSelector('.device-menu [role="menuitemradio"]');
const outPick = (await state(page)).items[Math.min(2, (await state(page)).items.length - 1)].label; const outPick = (await state(page)).items[Math.min(2, (await state(page)).items.length - 1)].label;
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
await page.click('#btn-deafen', { button: 'right' }); await page.click('#btn-deafen', { button: 'right' });
await page.waitForSelector('.device-menu [role="menuitemradio"]');
await page.click(`.device-menu [role="menuitemradio"]:has-text("${outPick.replace(/"/g, '\\"')}")`); await page.click(`.device-menu [role="menuitemradio"]:has-text("${outPick.replace(/"/g, '\\"')}")`);
await page.waitForTimeout(700); await page.waitForTimeout(700);
// Left click still toggles as before. // Left click still toggles as before.
@@ -91,16 +92,45 @@ try {
s = await state(page); s = await state(page);
step('left click still toggles mute', { inputMuted: s.audio.input_muted }); step('left click still toggles mute', { inputMuted: s.audio.input_muted });
await page.click('#btn-mute'); await page.click('#btn-mute');
// Races: enumeration is slowed to 600 ms. A second menu request or a dismissal while the first is
// pending must leave at most one current menu and never reopen or steal focus later.
await page.evaluate(() => {
const md = navigator.mediaDevices;
const original = md.enumerateDevices.bind(md);
md.enumerateDevices = () => new Promise((resolve, reject) => setTimeout(() => original().then(resolve, reject), 600));
});
await page.click('#btn-mute', { button: 'right' });
await page.click('#btn-deafen', { button: 'right' });
await page.waitForTimeout(1500);
const afterSwitch = await page.evaluate(() => ({
menus: document.querySelectorAll('.device-menu').length,
label: document.querySelector('.device-menu')?.getAttribute('aria-label'),
items: document.querySelectorAll('.device-menu [role="menuitemradio"]').length,
}));
step('rapid mic → headphones while enumeration pending', afterSwitch);
if (afterSwitch.menus !== 1 || afterSwitch.label !== 'Устройство вывода' || afterSwitch.items < 2) throw new Error('stale or duplicate menu');
await page.keyboard.press('Escape');
await page.click('#btn-mute', { button: 'right' });
await page.click('#connect-address');
await page.waitForTimeout(1500);
const afterDismiss = await page.evaluate(() => ({
menus: document.querySelectorAll('.device-menu').length,
focused: document.activeElement?.id ?? '',
expanded: document.querySelector('#btn-mute').getAttribute('aria-expanded'),
}));
step('dismissed before enumeration finished', afterDismiss);
if (afterDismiss.menus !== 0 || afterDismiss.focused !== 'connect-address' || afterDismiss.expanded !== 'false') throw new Error('menu reopened or focus stolen');
await app.close(); await app.close();
({ app, page } = await launch('run2')); ({ app, page } = await launch('run2'));
await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 }); await page.waitForSelector('#view-app', { state: 'visible', timeout: 20000 });
await page.click('#btn-mute', { button: 'right' }); await page.click('#btn-mute', { button: 'right' });
await page.waitForSelector('.device-menu'); await page.waitForSelector('.device-menu [role="menuitemradio"]');
const checkedIn = (await state(page)).items.find((i) => i.checked === 'true')?.label; const checkedIn = (await state(page)).items.find((i) => i.checked === 'true')?.label;
await page.keyboard.press('Escape'); await page.keyboard.press('Escape');
await page.click('#btn-deafen', { button: 'right' }); await page.click('#btn-deafen', { button: 'right' });
await page.waitForSelector('.device-menu'); await page.waitForSelector('.device-menu [role="menuitemradio"]');
const checkedOut = (await state(page)).items.find((i) => i.checked === 'true')?.label; const checkedOut = (await state(page)).items.find((i) => i.checked === 'true')?.label;
step('after restart', { checkedIn, checkedOut, persisted: checkedIn === pick && checkedOut === outPick }); step('after restart', { checkedIn, checkedOut, persisted: checkedIn === pick && checkedOut === outPick });
if (checkedIn !== pick || checkedOut !== outPick) throw new Error('menu choices not persisted'); if (checkedIn !== pick || checkedOut !== outPick) throw new Error('menu choices not persisted');
+14 -15
View File
@@ -63,6 +63,14 @@ async function setRange(page, selector, value) {
}, value); }, value);
} }
/** Transmit mode lives in Settings → Клавиши. */
async function setTransmit(page, mode) {
await page.click('#btn-settings');
await page.click('#settings-nav .nav-item[data-panel="keys"]');
await page.check('input[name="transmit"][value="' + mode + '"]');
await page.click('#settings-back');
}
async function connect(page) { async function connect(page) {
await page.fill('#connect-address', server); await page.fill('#connect-address', server);
await page.click('#connect-submit'); await page.click('#connect-submit');
@@ -79,6 +87,7 @@ try {
// B listens at zero playback gain so the test does not play tones on the speakers; frames still flow. // B listens at zero playback gain so the test does not play tones on the speakers; frames still flow.
await b.page.click('#btn-settings'); await b.page.click('#btn-settings');
await b.page.click('#settings-nav .nav-item[data-panel="audio"]');
await setRange(b.page, '#voice-volume', 0); await setRange(b.page, '#voice-volume', 0);
await b.page.click('#settings-back'); await b.page.click('#settings-back');
@@ -95,9 +104,7 @@ try {
if (others.length > 0) throw new Error(`refusing to transmit test tones: channel occupied by ${others.map((c) => c.nickname).join(', ')}`); if (others.length > 0) throw new Error(`refusing to transmit test tones: channel occupied by ${others.map((c) => c.nickname).join(', ')}`);
// A: open microphone. // A: open microphone.
await a.page.click('#btn-settings'); await setTransmit(a.page, 'open');
await a.page.check('input[name="transmit"][value="open"]');
await a.page.click('#settings-back');
// Open mic: B must see A talking and receive audio frames. // Open mic: B must see A talking and receive audio frames.
await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 20000); await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 20000);
@@ -119,9 +126,7 @@ try {
await a.page.click('#btn-mute'); await a.page.click('#btn-mute');
// Push-to-talk: switch A to PTT (default key F8), hold the key, release. // Push-to-talk: switch A to PTT (default key F8), hold the key, release.
await a.page.click('#btn-settings'); await setTransmit(a.page, 'ptt');
await a.page.check('input[name="transmit"][value="ptt"]');
await a.page.click('#settings-back');
await a.page.waitForTimeout(1500); await a.page.waitForTimeout(1500);
sb = await diag(b.page); sb = await diag(b.page);
step('PTT idle', { bTalkingIncludesA: sb.talking.includes(da.ownClientId) }); step('PTT idle', { bTalkingIncludesA: sb.talking.includes(da.ownClientId) });
@@ -135,18 +140,14 @@ try {
step('PTT burst received', { bFramesDuringBurst: (await diag(b.page)).voice.framesPlayed - before }); step('PTT burst received', { bFramesDuringBurst: (await diag(b.page)).voice.framesPlayed - before });
// Reverse direction: B talks to A. // Reverse direction: B talks to A.
await b.page.click('#btn-settings'); await setTransmit(b.page, 'open');
await b.page.check('input[name="transmit"][value="open"]');
await b.page.click('#settings-back');
await waitDiag(a.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), db.ownClientId, 20000); await waitDiag(a.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), db.ownClientId, 20000);
await a.page.waitForTimeout(2000); await a.page.waitForTimeout(2000);
sa = await diag(a.page); sa = await diag(a.page);
step('reverse direction received', { aFramesPlayed: sa.voice.framesPlayed, aTalking: sa.talking }); step('reverse direction received', { aFramesPlayed: sa.voice.framesPlayed, aTalking: sa.talking });
// Deafen B while both have open mics: B must stop receiving (RX) and stop sending (TX); undeafen resumes both. // Deafen B while both have open mics: B must stop receiving (RX) and stop sending (TX); undeafen resumes both.
await a.page.click('#btn-settings'); await setTransmit(a.page, 'open');
await a.page.check('input[name="transmit"][value="open"]');
await a.page.click('#settings-back');
await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 10000); await waitDiag(b.page, (clid) => window.teamspeachDiagnostics.snapshot().talking.includes(clid), da.ownClientId, 10000);
await b.page.click('#btn-deafen'); await b.page.click('#btn-deafen');
await waitDiag(b.page, () => window.teamspeachDiagnostics.snapshot().audio.output_muted === true, null, 10000); await waitDiag(b.page, () => window.teamspeachDiagnostics.snapshot().audio.output_muted === true, null, 10000);
@@ -165,9 +166,7 @@ try {
await b.page.waitForTimeout(2000); await b.page.waitForTimeout(2000);
step('B undeafened', { bRxDelta: (await diag(b.page)).voice.framesPlayed - rx1, aSeesBTalking: (await diag(a.page)).talking.includes(db.ownClientId) }); step('B undeafened', { bRxDelta: (await diag(b.page)).voice.framesPlayed - rx1, aSeesBTalking: (await diag(a.page)).talking.includes(db.ownClientId) });
for (const p of [a.page, b.page]) { for (const p of [a.page, b.page]) {
await p.click('#btn-settings'); await setTransmit(p, 'ptt');
await p.check('input[name="transmit"][value="ptt"]');
await p.click('#settings-back');
} }
// Chat: channel message A → B (the server may deny guests channel text: that error must be shown), // Chat: channel message A → B (the server may deny guests channel text: that error must be shown),
+15
View File
@@ -14,6 +14,21 @@ test('origins are compared after normalisation (Electron reports "app://teamspea
assert.equal(normalizeOrigin(undefined), ''); assert.equal(normalizeOrigin(undefined), '');
}); });
test('lookalike origins never match the app origin', () => {
for (const origin of [
'app://teamspeach@evil/',
'app://teamspeach.evil/',
'app://teamspeach\\@evil/',
'app://user:pass@teamspeach/',
'app://evil/teamspeach',
'apps://teamspeach/',
'app:teamspeach',
]) {
assert.notEqual(normalizeOrigin(origin), APP, origin);
assert.equal(permissionCheckAllowed('media', origin, { mediaType: 'audio' }, APP), false, origin);
}
});
test('permission checks: audio devices and output selection for the app only', () => { test('permission checks: audio devices and output selection for the app only', () => {
// Exactly the arguments observed from Electron 44 on Windows (requestingOrigin with trailing slash). // Exactly the arguments observed from Electron 44 on Windows (requestingOrigin with trailing slash).
assert.equal(permissionCheckAllowed('media', 'app://teamspeach/', { mediaType: 'audio', securityOrigin: 'app://teamspeach/' }, APP), true); assert.equal(permissionCheckAllowed('media', 'app://teamspeach/', { mediaType: 'audio', securityOrigin: 'app://teamspeach/' }, APP), true);