<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="../../resources/testharness.js"></script>
    <script src="../../resources/testharnessreport.js"></script>
</head>
<body>
    <script>
promise_test(async (test) => {
    if (!window.internals)
        return;
    if (window.testRunner)
        testRunner.setUserMediaPermission(false);

    await navigator.mediaDevices.getUserMedia({ audio: true }).then(assert_unreached, () => { });

    if (window.testRunner)
        testRunner.setUserMediaPermission(true);

    let promise;
    internals.withUserGesture(() => {
        promise = navigator.mediaDevices.getUserMedia({ audio: true }).then((stream) => {
            stream.getAudioTracks()[0].stop();
        }, assert_unreached);
    });
    await promise;

    return navigator.mediaDevices.getUserMedia({ audio: true });
}, "Remove audio denied request upon successful audio request");
    </script>
</body>
</html>
