Title: [213316] trunk
Revision
213316
Author
mra...@apple.com
Date
2017-03-02 15:50:59 -0800 (Thu, 02 Mar 2017)

Log Message

Media: send "did interfere with playback" events when the user pauses an autoplaying element
https://bugs.webkit.org/show_bug.cgi?id=169006

Reviewed by Alex Christensen.

Source/WebCore:

Added API tests.

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

Tools:

* TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html:
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(TEST): Added.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (213315 => 213316)


--- trunk/Source/WebCore/ChangeLog	2017-03-02 23:49:26 UTC (rev 213315)
+++ trunk/Source/WebCore/ChangeLog	2017-03-02 23:50:59 UTC (rev 213316)
@@ -1,3 +1,15 @@
+2017-02-28  Matt Rajca  <mra...@apple.com>
+
+        Media: send "did interfere with playback" events when the user pauses an autoplaying element
+        https://bugs.webkit.org/show_bug.cgi?id=169006
+
+        Reviewed by Alex Christensen.
+
+        Added API tests.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::pauseInternal):
+
 2017-03-02  Chris Dumez  <cdu...@apple.com>
 
         We should prevent load of subframes inserted during FrameTree deconstruction

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (213315 => 213316)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-03-02 23:49:26 UTC (rev 213315)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2017-03-02 23:50:59 UTC (rev 213316)
@@ -3256,6 +3256,12 @@
     }
 
     m_autoplaying = false;
+
+    if (ScriptController::processingUserGestureForMedia() && m_playbackWithoutUserGesture == PlaybackWithoutUserGesture::Started) {
+        if (Page* page = document().page())
+            page->chrome().client().handleAutoplayEvent(AutoplayEvent::UserDidInterfereWithPlayback);
+    }
+
     m_playbackWithoutUserGesture = PlaybackWithoutUserGesture::None;
 
     if (!m_paused) {

Modified: trunk/Tools/ChangeLog (213315 => 213316)


--- trunk/Tools/ChangeLog	2017-03-02 23:49:26 UTC (rev 213315)
+++ trunk/Tools/ChangeLog	2017-03-02 23:50:59 UTC (rev 213316)
@@ -1,3 +1,14 @@
+2017-02-28  Matt Rajca  <mra...@apple.com>
+
+        Media: send "did interfere with playback" events when the user pauses an autoplaying element
+        https://bugs.webkit.org/show_bug.cgi?id=169006
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
+        (TEST): Added.
+
 2017-03-02  Srinivasan Vijayaraghavan  <svijayaragha...@apple.com>
 
         Refactor test results classes in webkitpy to enable faster EWS iteration

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html (213315 => 213316)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html	2017-03-02 23:49:26 UTC (rev 213315)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/js-play-with-controls.html	2017-03-02 23:50:59 UTC (rev 213316)
@@ -9,7 +9,11 @@
             }
 
             function play() {
-                document.getElementById("video").play();
+                var video = document.getElementById("video");
+                if (video.paused)
+                    video.play();
+                else
+                    video.pause();
             }
 
             function mute() {

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm (213315 => 213316)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-03-02 23:49:26 UTC (rev 213315)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-03-02 23:50:59 UTC (rev 213316)
@@ -390,6 +390,16 @@
     [webView mouseDownAtPoint:muteButtonClickPoint simulatePressure:NO];
     [webView mouseUpAtPoint:muteButtonClickPoint];
     runUntilReceivesAutoplayEvent(kWKAutoplayEventUserDidInterfereWithPlayback);
+
+    receivedAutoplayEvent = std::nullopt;
+    [webView loadRequest:jsPlayRequest];
+    [webView waitForMessage:@"playing"];
+    ASSERT_TRUE(receivedAutoplayEvent == std::nullopt);
+
+    const NSPoint playButtonClickPoint = NSMakePoint(20, 256);
+    [webView mouseDownAtPoint:playButtonClickPoint simulatePressure:NO];
+    [webView mouseUpAtPoint:playButtonClickPoint];
+    runUntilReceivesAutoplayEvent(kWKAutoplayEventUserDidInterfereWithPlayback);
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to