Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Feature]: Controllable fake microphone input on all browsers

Aperta
#43,563 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, playwright, typescript

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🚀 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.

Lingua principale
TypeScript
Stelle
98k
Fork
6.6k
Merge medio
16h 1m
PR unite (30g)
309

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.