Change autoplay state to "prevented" when media is paused due to restrictions.
authormrajca@apple.com <mrajca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Apr 2017 18:29:03 +0000 (18:29 +0000)
committermrajca@apple.com <mrajca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Apr 2017 18:29:03 +0000 (18:29 +0000)
commite9957c8b4dfe19b8932538959e46ba9731f4c10c
tree97078f793a512a83a9b5f0d592223ff9a6305d4e
parent3585cf4dc70ebb54f60adecae563ffe0912e3652
Change autoplay state to "prevented" when media is paused due to restrictions.
https://bugs.webkit.org/show_bug.cgi?id=170686

Reviewed by Alex Christensen.

Source/WebCore:

Added API tests.

Currently, the autoplay state is set to "prevented" when playback is about to begin without
user interaction and there are restrictions in place. We should also be setting this flag when
autoplay is allowed but due to a change in audio tracks, for example, it gets paused.

This patch also moves some common logic into setPlaybackWithoutUserGesture without changing behavior.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setReadyState):
(WebCore::HTMLMediaElement::play):
(WebCore::HTMLMediaElement::mediaPlayerDidAddAudioTrack):
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged):
(WebCore::HTMLMediaElement::setPlaybackWithoutUserGesture):
(WebCore::HTMLMediaElement::updateShouldPlay):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html: Added test.
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215243 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/autoplay-muted-with-controls.html [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm