Title: [220035] trunk
Revision
220035
Author
[email protected]
Date
2017-07-28 17:25:49 -0700 (Fri, 28 Jul 2017)

Log Message

Don't add autoplay restrictions to media elements created in response to user gestures.
https://bugs.webkit.org/show_bug.cgi?id=174947

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/video-create-with-user-gesture.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):

LayoutTests:

Skip the test on iOS because "runWithKeyDown" does not work there.

Jer: "Turns out the problem with iOS is that the WKTR EventSender is basically unwritten. It
doesn't support sending mouse, key, or touch events, so our "do this during a user gesture"
helper in video-test.js doesn't work."

* media/video-create-with-user-gesture-expected.txt: Added.
* media/video-create-with-user-gesture.html: Added.
* platform/ios/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (220034 => 220035)


--- trunk/LayoutTests/ChangeLog	2017-07-28 23:21:10 UTC (rev 220034)
+++ trunk/LayoutTests/ChangeLog	2017-07-29 00:25:49 UTC (rev 220035)
@@ -1,3 +1,20 @@
+2017-07-28  Matt Rajca  <[email protected]>
+
+        Don't add autoplay restrictions to media elements created in response to user gestures.
+        https://bugs.webkit.org/show_bug.cgi?id=174947
+
+        Reviewed by Eric Carlson.
+
+        Skip the test on iOS because "runWithKeyDown" does not work there.
+
+        Jer: "Turns out the problem with iOS is that the WKTR EventSender is basically unwritten. It
+        doesn't support sending mouse, key, or touch events, so our "do this during a user gesture"
+        helper in video-test.js doesn't work."
+
+        * media/video-create-with-user-gesture-expected.txt: Added.
+        * media/video-create-with-user-gesture.html: Added.
+        * platform/ios/TestExpectations:
+
 2017-07-28  Per Arne Vollan  <[email protected]>
 
         The test imported/w3c/web-platform-tests/fetch/api/basic/accept-header.any.html is slow on Windows.

Added: trunk/LayoutTests/media/video-create-with-user-gesture-expected.txt (0 => 220035)


--- trunk/LayoutTests/media/video-create-with-user-gesture-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-create-with-user-gesture-expected.txt	2017-07-29 00:25:49 UTC (rev 220035)
@@ -0,0 +1,8 @@
+RUN(window.internals.settings.setVideoPlaybackRequiresUserGesture(true);)
+RUN(video = document.createElement("video"))
+RUN(video.src = "" "content/test"))
+RUN(video.setAttribute("autoplay", ""))
+RUN(document.body.appendChild(video))
+EVENT(playing)
+END OF TEST
+

Added: trunk/LayoutTests/media/video-create-with-user-gesture.html (0 => 220035)


--- trunk/LayoutTests/media/video-create-with-user-gesture.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-create-with-user-gesture.html	2017-07-29 00:25:49 UTC (rev 220035)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>video-create-with-user-gesture</title>
+    <script src=""
+    <script src=""
+    <script>
+    function runTest() {
+        run('window.internals.settings.setVideoPlaybackRequiresUserGesture(true);');
+        runWithKeyDown(() => {
+            run('video = document.createElement("video")');
+        });
+        run('video.src = "" "content/test")');
+        run('video.setAttribute("autoplay", "")');
+        run('document.body.appendChild(video)');
+        waitForEventAndEnd('playing');
+        failTestIn(10000);
+    }
+    </script>
+</head>
+<body _onload_="runTest()">
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (220034 => 220035)


--- trunk/LayoutTests/platform/ios/TestExpectations	2017-07-28 23:21:10 UTC (rev 220034)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2017-07-29 00:25:49 UTC (rev 220035)
@@ -2568,6 +2568,7 @@
 media/video-controls-fullscreen-volume.html
 media/video-controls-no-display-with-text-track.html
 media/video-controls-show-on-kb-or-ax-event.html
+media/video-create-with-user-gesture.html
 media/video-fullscreen-restriction-removed.html
 media/video-playsinline.html
 media/video-remote-control-playpause.html

Modified: trunk/Source/WebCore/ChangeLog (220034 => 220035)


--- trunk/Source/WebCore/ChangeLog	2017-07-28 23:21:10 UTC (rev 220034)
+++ trunk/Source/WebCore/ChangeLog	2017-07-29 00:25:49 UTC (rev 220035)
@@ -1,3 +1,15 @@
+2017-07-28  Matt Rajca  <[email protected]>
+
+        Don't add autoplay restrictions to media elements created in response to user gestures.
+        https://bugs.webkit.org/show_bug.cgi?id=174947
+
+        Reviewed by Eric Carlson.
+
+        Test: media/video-create-with-user-gesture.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::HTMLMediaElement):
+
 2017-07-28  Jeremy Jones  <[email protected]>
 
         WebMediaSessionHelper calls -[UIApplication beginReceivingRemoteControlEvents] from WebThread

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (220034 => 220035)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-07-28 23:21:10 UTC (rev 220034)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-07-29 00:25:49 UTC (rev 220035)
@@ -463,8 +463,9 @@
 
     if (document.ownerElement() || !document.isMediaDocument()) {
         const auto& topDocument = document.topDocument();
-        bool shouldAudioPlaybackRequireUserGesture = topDocument.audioPlaybackRequiresUserGesture();
-        bool shouldVideoPlaybackRequireUserGesture = topDocument.videoPlaybackRequiresUserGesture();
+        const bool isProcessingUserGesture = processingUserGestureForMedia();
+        const bool shouldAudioPlaybackRequireUserGesture = topDocument.audioPlaybackRequiresUserGesture() && !isProcessingUserGesture;
+        const bool shouldVideoPlaybackRequireUserGesture = topDocument.videoPlaybackRequiresUserGesture() && !isProcessingUserGesture;
 
         if (shouldVideoPlaybackRequireUserGesture) {
             m_mediaSession->addBehaviorRestriction(MediaElementSession::RequireUserGestureForVideoRateChange);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to