[Feature]: Controllable fake microphone input on all browsers
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, playwright, typescript
- Área
- backend-api-design, testing
Línea de trabajo
Read the linked requests #39297, #31158 and #27436, then inspect Playwright's browser permission and media device handling for Chromium, Firefox and WebKit. Reproduce the described getUserMedia behavior on each engine and compare it with the userland init-script example. Done means tests can control audio, playback timing and permission denial per page across all three browsers, or the issue's proposed documentation alternative is addressed.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🚀 Feature Request
Let a test control what the page's microphone delivers, per test and per page, on Chromium, Firefox and WebKit: a tone, an audio file, start and stop at a moment the test picks, and a permission denial.
#39297 asked for this and was closed as not planned. Two narrower requests, #31158 (control when the fake audio file plays) and #27436 (a different audio file per test), were closed for low engagement with a note asking for a new issue that links them. This is that issue.
What the stock browsers do today, measured on Playwright 1.63.0, macOS:
| Browser | getUserMedia({ audio: true }) |
|---|---|
| Chromium 153 | Works with --use-fake-device-for-media-stream. The audio is fixed for the whole browser at launch, and a file starts playing when capture starts. |
| Firefox 155 | grantPermissions(['microphone']) throws Unknown permission: microphone. With firefoxUserPrefs media.navigator.streams.fake and media.navigator.permission.disabled set to true, it resolves with a steady sine (1 kHz, or the pitch in media.navigator.audio.fake_frequency), fixed for the whole browser at launch. |
| WebKit 26.6, no grant | Rejects with NotAllowedError. |
WebKit 26.6, after grantPermissions(['microphone']) (new in 1.62 via #41836) |
Resolves with "Mock audio device 1", but the track is digital silence (rms 0 over 3 s through an AnalyserNode). |
Example
I maintain a userland version: playwright-mock-microphone (MIT, no dependencies, about 130 lines). Its suite records the mock through MediaRecorder and checks the recorded pitch on all three engines.
import { test, expect } from '@playwright/test';
import { mockMicrophone } from 'playwright-mock-microphone';
test('transcribes what the user says', async ({ page }) => {
const mic = await mockMicrophone(page);
await page.goto('/record');
await page.getByRole('button', { name: 'Record' }).click();
await mic.play('fixtures/hello.wav');
await mic.waitForEnd();
await expect(page.getByRole('status')).toHaveText('hello');
});
test('shows help when the microphone is blocked', async ({ page }) => {
const mic = await mockMicrophone(page);
await page.goto('/record');
await mic.deny('NotAllowedError');
await page.getByRole('button', { name: 'Record' }).click();
await expect(page.getByText('Allow microphone access')).toBeVisible();
});
It works by replacing getUserMedia and enumerateDevices from an init script and returning a Web Audio MediaStreamAudioDestinationNode stream. That approach has limits a built-in version would avoid: it bypasses the browser's permission layer, ignores constraints such as deviceId and echoCancellation, and leaves a global the page can see.
Motivation
Voice input is now common: speech to text, voice agents, voice memos, calls. Testing it means asserting on what the app does with known audio, so the test, not the launch config, has to choose the audio and when it plays. None of the three engines lets a test pick the audio at runtime. Chromium and Firefox fix it once per browser launch, and Firefox can only play a sine tone. WebKit, the engine iPad and Safari users run, delivers silence.
If you would rather keep this in userland, a docs note pointing to the init-script approach would still help the people who land on #2973 and #39297.
- Lenguaje dominante
- TypeScript
- Estrellas
- 98k
- Forks
- 6.6k
- Merge medio
- 15 h 59 min
- PR fusionados (30 d)
- 296
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/playwright
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
microsoft/playwright#43581 · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
[Feature]: Set `this.name` in `TargetClosedError` constructorQuizá libre de nuevo @LeonxLJX la tomó hace 49 días y no hay ningún pull request abierto. AbiertoP3-collecting-feedback
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
microsoft/playwright#42522 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
microsoft/playwright#43586 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
microsoft/playwright#43587 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 1-2 días Aptitud para principiantes 55/100
microsoft/playwright#43588 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/playwright
Issues similares
-
bug hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
libredb/libredb-studio#1941 ·
Los mantenedores suelen responder en 1 día
-
chore other
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
alastair-smith/card-games#308 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
paperclipai/paperclip#17379 ·
Los mantenedores suelen responder en 1 día
-
[good first issue, hacktoberfest] 🏯 Hacktoberfest Task - Add new Anime Quote 626 (good-first-issue)Abiertocommunity first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
lingdojo/kana-dojo#33040 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
bug mobile ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día