[iOS] remote command should be considered user events
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Apr 2016 22:09:43 +0000 (22:09 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Apr 2016 22:09:43 +0000 (22:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156546
<rdar://problem/25560877>

Reviewed by Jer Noble.

Source/WebCore:

Test: media/remote-control-command-is-user-gesture.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::didReceiveRemoteControlCommand): Increment/decrement
  m_processingRemoteControlCommand around calling remote command method.
(WebCore::HTMLMediaElement::processingUserGesture): Return true if called while handling
  a remote control command.
* html/HTMLMediaElement.h:

LayoutTests:

* media/remote-control-command-is-user-gesture-expected.txt: Added.
* media/remote-control-command-is-user-gesture.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/media/remote-control-command-is-user-gesture-expected.txt [new file with mode: 0644]
LayoutTests/media/remote-control-command-is-user-gesture.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.cpp

index 5f56d45..79301b6 100644 (file)
@@ -1,3 +1,14 @@
+2016-04-13  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] remote command should be considered user events
+        https://bugs.webkit.org/show_bug.cgi?id=156546
+        <rdar://problem/25560877>
+
+        Reviewed by Jer Noble.
+
+        * media/remote-control-command-is-user-gesture-expected.txt: Added.
+        * media/remote-control-command-is-user-gesture.html: Added.
+
 2016-04-13  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r199502 and r199511.
diff --git a/LayoutTests/media/remote-control-command-is-user-gesture-expected.txt b/LayoutTests/media/remote-control-command-is-user-gesture-expected.txt
new file mode 100644 (file)
index 0000000..16be059
--- /dev/null
@@ -0,0 +1,17 @@
+Test that a remote control command is treated as a user gesture.
+
+
+RUN(internals.setMediaElementRestrictions(video, "RequireUserGestureForVideoRateChange"))
+* set video.src
+EVENT(loadedmetadata)
+
+* video.play() should fail 
+RUN(video.play())
+EXPECTED (video.paused == 'true') OK
+
+* Send a play command, it should succeed.
+RUN(internals.postRemoteControlCommand('play'))
+
+EVENT(timeupdate)
+END OF TEST
+
diff --git a/LayoutTests/media/remote-control-command-is-user-gesture.html b/LayoutTests/media/remote-control-command-is-user-gesture.html
new file mode 100644 (file)
index 0000000..d401b34
--- /dev/null
@@ -0,0 +1,43 @@
+<html>
+    <head>
+        <script src="media-file.js"></script>
+        <script src="video-test.js"></script>
+        <script>
+
+            function start()
+            {
+                if (!window.internals) {
+                    failTest('This test requires window.internals.');
+                    return;
+                }
+
+                findMediaElement();
+
+                run('internals.setMediaElementRestrictions(video, "RequireUserGestureForVideoRateChange")');
+
+                waitForEvent('loadedmetadata', loadedmetadata, false, true, document)
+                waitForEventAndEnd('timeupdate')
+
+                consoleWrite('* set video.src');
+                video.src = findMediaFile('video', 'content/test');
+            }
+
+            function loadedmetadata()
+            {
+                consoleWrite('<br>* video.play() should fail ');
+                run('video.play()');
+                testExpected('video.paused', true);
+
+                consoleWrite('<br>* Send a play command, it should succeed.');
+                run("internals.postRemoteControlCommand('play')");
+                consoleWrite('');
+            }
+
+        </script>
+    </head>
+
+    <body onload="start()">
+        <p>Test that a remote control command is treated as a user gesture.</p>
+        <video controls></video>
+    </body>
+</html>
index dc208ea..c1dfc21 100644 (file)
@@ -1,3 +1,20 @@
+2016-04-13  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] remote command should be considered user events
+        https://bugs.webkit.org/show_bug.cgi?id=156546
+        <rdar://problem/25560877>
+
+        Reviewed by Jer Noble.
+
+        Test: media/remote-control-command-is-user-gesture.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::didReceiveRemoteControlCommand): Increment/decrement 
+          m_processingRemoteControlCommand around calling remote command method.
+        (WebCore::HTMLMediaElement::processingUserGesture): Return true if called while handling
+          a remote control command.
+        * html/HTMLMediaElement.h:
+
 2016-04-13  Antonio Gomes  <tonikitoo@webkit.org>
 
         Non-resizable text field looks resizable
index b446242..8b37070 100644 (file)
@@ -85,6 +85,7 @@
 #include "ShadowRoot.h"
 #include "TimeRanges.h"
 #include "UserContentController.h"
+#include "UserGestureIndicator.h"
 #include <limits>
 #include <runtime/Uint8Array.h>
 #include <wtf/CurrentTime.h>
@@ -6640,6 +6641,7 @@ void HTMLMediaElement::didReceiveRemoteControlCommand(PlatformMediaSession::Remo
 {
     LOG(Media, "HTMLMediaElement::didReceiveRemoteControlCommand(%p) - %i", this, static_cast<int>(command));
 
+    UserGestureIndicator remoteControlUserGesture(DefinitelyProcessingUserGesture, &document());
     switch (command) {
     case PlatformMediaSession::PlayCommand:
         play();