Trying to play a media element synchronously after setting srcObject should succeed...
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2018 01:17:57 +0000 (01:17 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2018 01:17:57 +0000 (01:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192679

Reviewed by Eric Carlson.

Source/WebCore:

Check the srcObject mediaProvider value which is set synchronously.
Covered by updated fast/mediastream/local-audio-playing-event.html.

* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::hasMediaStreamSrcObject const):

LayoutTests:

* fast/mediastream/local-audio-playing-event-expected.txt:
* fast/mediastream/local-audio-playing-event.html:

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

LayoutTests/ChangeLog
LayoutTests/fast/mediastream/local-audio-playing-event-expected.txt
LayoutTests/fast/mediastream/local-audio-playing-event.html
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLMediaElement.h

index 068bdaf..f2c1c3c 100644 (file)
@@ -1,3 +1,13 @@
+2018-12-13  Youenn Fablet  <youenn@apple.com>
+
+        Trying to play a media element synchronously after setting srcObject should succeed without user gesture
+        https://bugs.webkit.org/show_bug.cgi?id=192679
+
+        Reviewed by Eric Carlson.
+
+        * fast/mediastream/local-audio-playing-event-expected.txt:
+        * fast/mediastream/local-audio-playing-event.html:
+
 2018-12-13  Per Arne Vollan  <pvollan@apple.com>
 
         [macOS] Inline WebVTT styles should override styles from Captions settings in System Preferences
index 714564f..359727f 100644 (file)
@@ -1,3 +1,4 @@
 
 PASS Local audio playback fires playing event 
+PASS Calling play synchronously after setting srcObject shoud play and fire playing event 
 
index ac7bb30..dc49e58 100644 (file)
@@ -8,19 +8,23 @@
 </head>
 <body>
     <audio id="audio" autoplay></audio>
+    <audio id="audioNoAutoplay" autoplay></audio>
     <script>
     if (window.testRunner)
         testRunner.setUserMediaPermission(true);
 
-    var audio = document.getElementById('audio');
-
-    promise_test((test) => {
-        return navigator.mediaDevices.getUserMedia({audio: true}).then((stream) => {
-            audio.srcObject = stream;
-            var eventWatcher = new EventWatcher(test, audio, 'playing');
-            return eventWatcher.wait_for('playing');
-        });
+    promise_test(async (test) => {
+        audio.srcObject = await navigator.mediaDevices.getUserMedia({audio: true});
+        var eventWatcher = new EventWatcher(test, audio, 'playing');
+        return eventWatcher.wait_for('playing');
     }, 'Local audio playback fires playing event');
+
+    promise_test(async (test) => {
+        audioNoAutoplay.srcObject = await navigator.mediaDevices.getUserMedia({audio: true});
+        audioNoAutoplay.play();
+        var eventWatcher = new EventWatcher(test, audioNoAutoplay, 'playing');
+        return eventWatcher.wait_for('playing');
+    }, 'Calling play synchronously after setting srcObject shoud play and fire playing event');
     </script>
 </body>
 </html>
index e3922d2..a7f8cfa 100644 (file)
@@ -1,3 +1,16 @@
+2018-12-13  Youenn Fablet  <youenn@apple.com>
+
+        Trying to play a media element synchronously after setting srcObject should succeed without user gesture
+        https://bugs.webkit.org/show_bug.cgi?id=192679
+
+        Reviewed by Eric Carlson.
+
+        Check the srcObject mediaProvider value which is set synchronously.
+        Covered by updated fast/mediastream/local-audio-playing-event.html.
+
+        * html/HTMLMediaElement.h:
+        (WebCore::HTMLMediaElement::hasMediaStreamSrcObject const):
+
 2018-12-13  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Support dropping contact card data (public.vcard) in editable content
index 360af86..0c87159 100644 (file)
@@ -553,7 +553,7 @@ public:
 
 #if ENABLE(MEDIA_STREAM)
     void mediaStreamCaptureStarted() { resumeAutoplaying(); }
-    bool hasMediaStreamSrcObject() const { return !!m_mediaStreamSrcObject; }
+    bool hasMediaStreamSrcObject() const { return m_mediaProvider && WTF::holds_alternative<RefPtr<MediaStream>>(*m_mediaProvider); }
 #endif
 
     bool supportsSeeking() const override;