Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Feature]: Controllable fake microphone input on all browsers

Abierto
#43,563 1 comentario 0 reacciones 0 asignados Ver en GitHub

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

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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/playwright

Todos los issues de microsoft/playwright

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.