forked from WebKit/WebKit-http
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio-playback-restriction-removed-track-enabled.html
61 lines (49 loc) · 1.61 KB
/
audio-playback-restriction-removed-track-enabled.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!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>