[Feature]: Controllable fake microphone input on all browsers
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
- Ambito
- backend-api-design, testing
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
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/playwright
-
[Feature]: Set `this.name` in `TargetClosedError` constructorForse di nuovo libera @LeonxLJX l’ha presa 48 giorni fa e non c’è nessuna pull request aperta. ApertaP3-collecting-feedback
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
microsoft/playwright#42522 · 7 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
microsoft/playwright#43564 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: `request.response()` never resolves for a service worker's own script when many contexts register service workers at onceForse già presa @pavelfeldman l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
microsoft/playwright#43562 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]:Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
microsoft/playwright#43559 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
microsoft/playwright#43557 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/playwright
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
maniator/verticopolis#1303 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
components-web-app/docs#297 ·
-
listFeatures/getFeatureExamples never return Kotlin examples for Android or server Kotlin SDKsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
appwrite/mcp-for-docs#23 · 1 commento ·
-
`@vanilla-extract/turbopack-plugin`: "getImageSize is not a function" with Next.js 16.4.x when a `.css.ts` file imports an imageForse già presa @aevarOrigo l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vanilla-extract-css/vanilla-extract#1799 · 1 commento ·
-
native
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
prime-radiant-inc/evener#4839 ·
I maintainer di solito rispondono entro 1 giorno