// Run in mic.html (a normal tab): asks for mic permission once so offscreen.js can use it later without a prompt. navigator.mediaDevices.getUserMedia({ audio: true }) // Stop the probe tracks at once: only the permission grant was needed, not the audio. .then(stream => { stream.getTracks().forEach(track => track.stop()); document.body.append(" granted."); }) // Show the outcome in the page (the error text if the user denied or the call failed). .catch(error => document.body.append(" " + error));