haikuwebkit/LayoutTests/media/audio-playback-restriction-...

62 lines
1.6 KiB
HTML
Raw Permalink Normal View History

[iOS] Make HTMLMediaElement.muted mutable https://bugs.webkit.org/show_bug.cgi?id=158787 <rdar://problem/24452567> Reviewed by Dean Jackson. Source/WebCore: Tests: media/audio-playback-restriction-removed-muted.html media/audio-playback-restriction-removed-track-enabled.html * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::audioTrackEnabledChanged): Remove most behavior restrictions if the track state was changed as a result of a user gesture. (WebCore::HTMLMediaElement::setMuted): Ditto. (WebCore::HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture): Add mask parameter so caller can choose which restrictions are removed. * html/HTMLMediaElement.h: * html/MediaElementSession.cpp: (WebCore::restrictionName): Drive-by fix: remove duplicate label. * html/MediaElementSession.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Set muted on AVPlayer if setMuted was called before the player was created. (WebCore::MediaPlayerPrivateAVFoundationObjC::setVolume): Drive-by fix: return early if there is no AVPlayer, not if we won't have metadata yet. (WebCore::MediaPlayerPrivateAVFoundationObjC::setMuted): New. LayoutTests: * media/audio-playback-restriction-removed-muted-expected.txt: Added. * media/audio-playback-restriction-removed-muted.html: Added. * media/audio-playback-restriction-removed-track-enabled-expected.txt: Added. * media/audio-playback-restriction-removed-track-enabled.html: Added. Canonical link: https://commits.webkit.org/176879@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202100 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-15 19:32:50 +00:00
<!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>