| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>audio-playback-restriction</title> |
| <script src=media-file.js></script> |
| <script src=video-test.js></script> |
| |
| <script> |
| |
| let audioTrack = null; |
| function runTest() |
| { |
| video = document.getElementsByTagName('audio')[0]; |
| |
| if (window.internals) |
| run(`internals.setMediaElementRestrictions(video, 'RequireUserGestureForAudioRateChange')`); |
| |
| waitForEventAndFail('error'); |
| waitForEvent('canplaythrough', canplaythrough); |
| run(`video.src = findMediaFile('video', 'content/audio-tracks')`); |
| } |
| |
| function canplaythrough() |
| { |
| waitForEvent('playing', playing); |
| video.audioTracks.addEventListener('change', setMuted, true); |
| run('video.play()'); |
| } |
| |
| function playing() |
| { |
| for (let i = 0; i < video.audioTracks.length; i++) { |
| if (video.audioTracks[i].enabled) |
| continue; |
| |
| audioTrack = video.audioTracks[i]; |
| break; |
| } |
| if (audioTrack === null) |
| failTest('Failed to find disabled audio track!'); |
| |
| runWithKeyDown('audioTrack.enabled = true'); |
| } |
| |
| function setMuted() |
| { |
| waitForEventAndFail('pause'); |
| video.audioTracks.removeEventListener('change', setMuted, true); |
| run('video.muted = false'); |
| setTimeout(endTest, 250); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload='runTest()'> |
| <p>Test that when RequireUserGestureForAudioRateChange is set, enabling an audio track with a user gesture clears the restriction.</p> |
| <audio muted controls></audio> |
| </body> |
| </html> |
| |