Unprefix webkit-playsinline.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jun 2016 00:12:07 +0000 (00:12 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jun 2016 00:12:07 +0000 (00:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159283

Reviewed by Eric Carlson.

Tests: media/video-playsinline.html
       media/video-webkit-playsinline.html

Unprefix the webkit-playsinline content attribute, as an unprefixed version
was added to the HTML spec by <https://github.com/whatwg/html/pull/1444>.
The new 'playsinline' content attribute reflects to a new DOM property of
the same name.

* html/HTMLAttributeNames.in:
* html/HTMLVideoElement.idl:
* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202660 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/media/video-playsinline-expected.txt [new file with mode: 0644]
LayoutTests/media/video-playsinline.html [new file with mode: 0644]
LayoutTests/media/video-webkit-playsinline-expected.txt [new file with mode: 0644]
LayoutTests/media/video-webkit-playsinline.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAttributeNames.in
Source/WebCore/html/HTMLVideoElement.idl
Source/WebCore/html/MediaElementSession.cpp

diff --git a/LayoutTests/media/video-playsinline-expected.txt b/LayoutTests/media/video-playsinline-expected.txt
new file mode 100644 (file)
index 0000000..ec59df9
--- /dev/null
@@ -0,0 +1,26 @@
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(true))
+RUN(video.playsinline = false)
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(true))
+RUN(video.playsinline = true)
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(false))
+RUN(video.playsinline = false)
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(false))
+RUN(video.playsinline = true)
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+END OF TEST
+
diff --git a/LayoutTests/media/video-playsinline.html b/LayoutTests/media/video-playsinline.html
new file mode 100644 (file)
index 0000000..c9935d0
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="media-file.js"></script>
+<script src="video-test.js"></script>
+<script>
+function go()
+{
+    runNextTest();
+}
+
+function runNextTest()
+{
+    if (tests.length)
+        tests.shift()();
+    else
+        endTest();
+}
+
+function testPlaysInline(requiresPlaysInline, hasPlaysInline, expectedDisplayingFullscreen)
+{
+    run('internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(' + requiresPlaysInline + ')');
+    video = media = document.createElement('video');
+    document.body.appendChild(video);
+    video.controls = true;
+    video.src = findMediaFile('video', 'content/test');
+    run('video.playsinline = ' + hasPlaysInline);
+    waitForEventOnce('canplaythrough', () => {
+        runWithKeyDown(() => {
+            run('video.play()');
+        });
+    })
+    waitForEventOnce('playing', () => {
+        testExpected('video.webkitDisplayingFullscreen', expectedDisplayingFullscreen);
+        document.body.removeChild(video);
+        runNextTest();
+    });
+}
+
+function testRequiresPlaysInlineAndDoesntHaveIt()
+{
+    testPlaysInline(true, false, true);
+}
+
+function testRequiresPlaysInlineAndDoesHaveIt()
+{
+    testPlaysInline(true, true, false);
+}
+
+function testDoesNotRequirePlaysInlineAndDoesntHaveIt()
+{
+    testPlaysInline(false, false, false);
+}
+
+function testDoesNotRequirePlaysInlineAndDoesHaveIt()
+{
+    testPlaysInline(false, true, false);
+}
+
+var tests = [
+    testRequiresPlaysInlineAndDoesntHaveIt,
+    testRequiresPlaysInlineAndDoesHaveIt,
+    testDoesNotRequirePlaysInlineAndDoesntHaveIt,
+    testDoesNotRequirePlaysInlineAndDoesHaveIt,
+];
+
+</script>
+</head>
+<body onload="go()">
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/media/video-webkit-playsinline-expected.txt b/LayoutTests/media/video-webkit-playsinline-expected.txt
new file mode 100644 (file)
index 0000000..7ade33c
--- /dev/null
@@ -0,0 +1,26 @@
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(true))
+RUN(video.removeAttribute("webkit-playsinline"))
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'true') OK
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(true))
+RUN(video.setAttribute("webkit-playsinline"))
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(false))
+RUN(video.removeAttribute("webkit-playsinline"))
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+RUN(internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(false))
+RUN(video.setAttribute("webkit-playsinline"))
+EVENT(canplaythrough)
+RUN(video.play())
+EVENT(playing)
+EXPECTED (video.webkitDisplayingFullscreen == 'false') OK
+END OF TEST
+
diff --git a/LayoutTests/media/video-webkit-playsinline.html b/LayoutTests/media/video-webkit-playsinline.html
new file mode 100644 (file)
index 0000000..c6251c2
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="media-file.js"></script>
+<script src="video-test.js"></script>
+<script>
+function go()
+{
+    runNextTest();
+}
+
+function runNextTest()
+{
+    if (tests.length)
+        tests.shift()();
+    else
+        endTest();
+}
+
+function testPlaysInline(requiresPlaysInline, hasWebkitPlaysInline, expectedDisplayingFullscreen)
+{
+    run('internals.settings.setInlineMediaPlaybackRequiresPlaysInlineAttribute(' + requiresPlaysInline + ')');
+    video = media = document.createElement('video');
+    document.body.appendChild(video);
+    video.controls = true;
+    video.src = findMediaFile('video', 'content/test');
+    run('video.' + (hasWebkitPlaysInline ? 'set' : 'remove') + 'Attribute("webkit-playsinline")');
+    waitForEventOnce('canplaythrough', () => {
+        runWithKeyDown(() => {
+            run('video.play()');
+        });
+    })
+    waitForEventOnce('playing', () => {
+        testExpected('video.webkitDisplayingFullscreen', expectedDisplayingFullscreen);
+        document.body.removeChild(video);
+        runNextTest();
+    });
+}
+
+function testRequiresPlaysInlineAndDoesntHaveIt()
+{
+    testPlaysInline(true, false, true);
+}
+
+function testRequiresPlaysInlineAndDoesHaveIt()
+{
+    testPlaysInline(true, true, false);
+}
+
+function testDoesNotRequirePlaysInlineAndDoesntHaveIt()
+{
+    testPlaysInline(false, false, false);
+}
+
+function testDoesNotRequirePlaysInlineAndDoesHaveIt()
+{
+    testPlaysInline(false, true, false);
+}
+
+var tests = [
+    testRequiresPlaysInlineAndDoesntHaveIt,
+    testRequiresPlaysInlineAndDoesHaveIt,
+    testDoesNotRequirePlaysInlineAndDoesntHaveIt,
+    testDoesNotRequirePlaysInlineAndDoesHaveIt,
+];
+
+</script>
+</head>
+<body onload="go()">
+</body>
+</html>
\ No newline at end of file
index b75d349..ea9afd2 100644 (file)
@@ -1,3 +1,23 @@
+2016-06-29  Jer Noble  <jer.noble@apple.com>
+
+        Unprefix webkit-playsinline.
+        https://bugs.webkit.org/show_bug.cgi?id=159283
+
+        Reviewed by Eric Carlson.
+
+        Tests: media/video-playsinline.html
+               media/video-webkit-playsinline.html
+
+        Unprefix the webkit-playsinline content attribute, as an unprefixed version
+        was added to the HTML spec by <https://github.com/whatwg/html/pull/1444>.
+        The new 'playsinline' content attribute reflects to a new DOM property of
+        the same name.
+
+        * html/HTMLAttributeNames.in:
+        * html/HTMLVideoElement.idl:
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::requiresFullscreenForVideoPlayback):
+
 2016-06-29  Alex Christensen  <achristensen@webkit.org>
 
         Fix null dereferencing after r201441
index 91f7ae9..acfeb64 100644 (file)
@@ -299,6 +299,7 @@ open
 optimum
 pattern
 placeholder
+playsinline
 pluginspage
 pluginurl
 ping
index b82855e..0bec02c 100644 (file)
@@ -33,6 +33,7 @@
     readonly attribute unsigned long videoHeight;
     [Reflect, URL] attribute DOMString poster;
 
+    [Reflect] attribute boolean playsinline;
     readonly attribute boolean webkitSupportsFullscreen;
     readonly attribute boolean webkitDisplayingFullscreen;
 
index cea8517..3843423 100644 (file)
@@ -450,7 +450,7 @@ bool MediaElementSession::requiresFullscreenForVideoPlayback(const HTMLMediaElem
     if (!settings || !settings->allowsInlineMediaPlayback())
         return true;
 
-    return settings->inlineMediaPlaybackRequiresPlaysInlineAttribute() && !element.fastHasAttribute(HTMLNames::webkit_playsinlineAttr);
+    return settings->inlineMediaPlaybackRequiresPlaysInlineAttribute() && !(element.fastHasAttribute(HTMLNames::webkit_playsinlineAttr) || element.fastHasAttribute(HTMLNames::playsinlineAttr));
 }
 
 bool MediaElementSession::allowsAutomaticMediaDataLoading(const HTMLMediaElement& element) const