Changeset 223144 in webkit


Ignore:
Timestamp:
Oct 10, 2017 2:26:03 PM (7 years ago)
Author:
mrajca@apple.com
Message:

Respect audio rate change restrictions in HTMLMediaElement::setVolume.
https://bugs.webkit.org/show_bug.cgi?id=178140

Reviewed by Eric Carlson.

Source/WebCore:

Tests: media/audio-playback-volume-changes-with-restrictions-and-user-gestures.html

media/audio-playback-volume-changes-with-restrictions.html

It's currently possible for a website to start auto-playing media with a zero volume and then
programmatically set the volume to a non-zero value without a user gesture. This code path didn't
have to be considered previously because volume changes are not supported on iOS.

We currently pause media when an audio track comes in after an element has already started playing silently
in mediaPlayerDidAddAudioTrack. This patch does the same when a non-zero volume is set after a media
element already began playing silently and there is an audio rate change restriction.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::setVolume):

LayoutTests:

  • media/audio-playback-volume-changes-with-restrictions-and-user-gestures-expected.txt: Added.
  • media/audio-playback-volume-changes-with-restrictions-and-user-gestures.html: Added.
  • media/audio-playback-volume-changes-with-restrictions-expected.txt: Added.
  • media/audio-playback-volume-changes-with-restrictions.html: Added.
  • platform/ios/TestExpectations:
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223140 r223144  
     12017-10-10  Matt Rajca  <mrajca@apple.com>
     2
     3        Respect audio rate change restrictions in HTMLMediaElement::setVolume.
     4        https://bugs.webkit.org/show_bug.cgi?id=178140
     5
     6        Reviewed by Eric Carlson.
     7
     8        * media/audio-playback-volume-changes-with-restrictions-and-user-gestures-expected.txt: Added.
     9        * media/audio-playback-volume-changes-with-restrictions-and-user-gestures.html: Added.
     10        * media/audio-playback-volume-changes-with-restrictions-expected.txt: Added.
     11        * media/audio-playback-volume-changes-with-restrictions.html: Added.
     12        * platform/ios/TestExpectations:
     13
    1142017-10-10  Ryosuke Niwa  <rniwa@webkit.org>
    215
  • trunk/LayoutTests/platform/ios/TestExpectations

    r223140 r223144  
    382382media/restricted-audio-playback-with-document-gesture.html [ Skip ]
    383383media/restricted-audio-playback-with-multiple-settimeouts.html [ Skip ]
     384media/audio-playback-volume-changes-with-restrictions.html [ Skip ]
     385media/audio-playback-volume-changes-with-restrictions-and-user-gestures.html [ Skip ]
    384386storage/domstorage/sessionstorage/set-item-synchronous-keydown.html [ Skip ]
    385387
  • trunk/Source/WebCore/ChangeLog

    r223140 r223144  
     12017-10-10  Matt Rajca  <mrajca@apple.com>
     2
     3        Respect audio rate change restrictions in HTMLMediaElement::setVolume.
     4        https://bugs.webkit.org/show_bug.cgi?id=178140
     5
     6        Reviewed by Eric Carlson.
     7
     8        Tests: media/audio-playback-volume-changes-with-restrictions-and-user-gestures.html
     9               media/audio-playback-volume-changes-with-restrictions.html
     10
     11        It's currently possible for a website to start auto-playing media with a zero volume and then
     12        programmatically set the volume to a non-zero value without a user gesture. This code path didn't
     13        have to be considered previously because volume changes are not supported on iOS.
     14
     15        We currently pause media when an audio track comes in after an element has already started playing silently
     16        in mediaPlayerDidAddAudioTrack. This patch does the same when a non-zero volume is set after a media
     17        element already began playing silently and there is an audio rate change restriction.
     18
     19        * html/HTMLMediaElement.cpp:
     20        (WebCore::HTMLMediaElement::setVolume):
     21
    1222017-10-10  Ryosuke Niwa  <rniwa@webkit.org>
    223
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r222473 r223144  
    35683568        return { };
    35693569
     3570    if (volume && processingUserGestureForMedia())
     3571        removeBehaviorsRestrictionsAfterFirstUserGesture(MediaElementSession::AllRestrictions & ~MediaElementSession::RequireUserGestureToControlControlsManager);
     3572
    35703573    m_volume = volume;
    35713574    m_volumeInitialized = true;
    35723575    updateVolume();
    35733576    scheduleEvent(eventNames().volumechangeEvent);
     3577
     3578    if (isPlaying() && !m_mediaSession->playbackPermitted(*this)) {
     3579        pauseInternal();
     3580        setPlaybackWithoutUserGesture(PlaybackWithoutUserGesture::Prevented);
     3581    }
    35743582#endif
    35753583    return { };
Note: See TracChangeset for help on using the changeset viewer.