<!DOCTYPE html>
<html>
<head>
    <title>audio-session-category-track-change</title>
    <script src="../../../media/video-test.js"></script>
    <script src="../../../media/media-file.js"></script>
    <script>
    function go() {
        findMediaElement();
        run('internals.settings.setShouldManageAudioSessionCategory(true)');
        run('video.src = findMediaFile("video", "../../../media/content/test")');
        waitForEvent('canplay', canplay);
    }

    function canplay() {
        testExpected('internals.audioSessionCategory()', 'None');
        run('video.audioTracks[0].enabled = false');
        waitForEventOnceOn(video.audioTracks, 'change', trackDisabled);
    }

    function trackDisabled() {
        testExpected('internals.audioSessionCategory()', 'None');
        run('video.muted = false');
        waitForEvent('volumechange', volumechange);
    }

    function volumechange() {
        testExpected('internals.audioSessionCategory()', 'None');
        run('video.play()');
        waitForEvent('playing', playing);
    }

    function playing() {
        testExpected('internals.audioSessionCategory()', 'None');
        run('video.audioTracks[0].enabled = true');
        waitForEventOnceOn(video.audioTracks, 'change', trackEnabled);
    }

    function trackEnabled() {
        testExpected('internals.audioSessionCategory()', 'MediaPlayback');
        endTest();
    }
    </script>
</head>
<body onload="go()">
    <video controls muted></video>
</body>
</html>