Allow multiple playing videos on a page with 'autoplay' and 'playsinline' attributes
https://bugs.webkit.org/show_bug.cgi?id=162366
<rdar://problem/28639600>

Reviewed by Eric Carlson.

Source/WebCore:

Tests: media/video-concurrent-visible-playback.html
       media/video-multiple-concurrent-playback.html

Separate out the concept of "video-only" from "video-with-audio" in PlatformMediaSession::MediaType,
and only set the ConcurrentPlaybackNotPermitted restriction for "video-with-audio".  This allows multiple
silent video elements to play back simultaneously.

However, the bug in question also shows bad behavior when both concurrent playback and invisible playback
are not allowed. Namely, an invisible element will attempt to autoplay, interrupt visible elements, and
then fail to play due to it's non-visibility.  Add an extra check to canTransitionFromAutoplayToPlay()
which asks the session if autoplay is allowed (which will return false if the element is not visible).

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay):
(WebCore::HTMLMediaElement::mediaType):
(WebCore::HTMLMediaElement::presentationType):
(WebCore::HTMLMediaElement::updateShouldAutoplay):
(WebCore::mediaElementIsAllowedToAutoplay): Deleted.
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::autoplayPermitted):
* html/MediaElementSession.h:
* platform/audio/PlatformMediaSession.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::resetRestrictions):
* testing/Internals.cpp:
(WebCore::Internals::setMediaSessionRestrictions):

LayoutTests:

* media/content/test-video-only.mp4: Added.
* media/non-existent-video-playback-interrupted-expected.txt:
* media/non-existent-video-playback-interrupted.html:
* media/video-background-playback-expected.txt:
* media/video-background-playback.html:
* media/video-background-tab-playback-expected.txt:
* media/video-background-tab-playback.html:
* media/video-concurrent-playback-expected.txt:
* media/video-concurrent-playback.html:
* media/video-concurrent-visible-playback-expected.txt: Added.
* media/video-concurrent-visible-playback.html: Added.
* media/video-multiple-concurrent-playback-expected.txt: Added.
* media/video-multiple-concurrent-playback.html: Added.
* media/video-playback-interrupted-expected.txt:
* media/video-playback-interrupted.html:
* media/video-restricted-invisible-autoplay-not-allowed.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@208149 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/media/video-background-playback.html b/LayoutTests/media/video-background-playback.html
index e5e1cd8..4574214 100644
--- a/LayoutTests/media/video-background-playback.html
+++ b/LayoutTests/media/video-background-playback.html
@@ -78,7 +78,7 @@
                 audio = elements[1];
                 audio.src = findMediaFile("audio", "content/silence");
 
-                run("internals.setMediaSessionRestrictions('video', 'BackgroundProcessPlaybackRestricted')");
+                run("internals.setMediaSessionRestrictions('videoaudio', 'BackgroundProcessPlaybackRestricted')");
                 state = "foreground";
                 consoleWrite("");
             }