Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE HTML>
<html>
<body>
<pre id="test">
<script type="application/javascript">
/**
Runs inside iframe in test_enumerateDevices.html.
*/
const pushPrefs = (...p) => SpecialPowers.pushPrefEnv({set: p});
const gUM = c => navigator.mediaDevices.getUserMedia(c);
(async () => {
await pushPrefs(["media.navigator.streams.fake", true]);
// Validate enumerated devices after gUM.
for (const track of (await gUM({video: true, audio: true})).getTracks()) {
track.stop();
}
const devices = await navigator.mediaDevices.enumerateDevices();
parent.postMessage(JSON.stringify(devices), "https://example.com:443");
})().catch(e => setTimeout(() => { throw e; }));
</script>
</pre>
</body>
</html>