Title: [225785] trunk
Revision
225785
Author
[email protected]
Date
2017-12-12 09:26:34 -0800 (Tue, 12 Dec 2017)

Log Message

Allow AudioContext to start when getUserMedia is on
https://bugs.webkit.org/show_bug.cgi?id=180680

Patch by Youenn Fablet <[email protected]> on 2017-12-12
Reviewed by Eric Carlson.

Source/WebCore:

Test: webrtc/getUserMedia-webaudio-autoplay.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::willBeginPlayback):

LayoutTests:

* webrtc/getUserMedia-webaudio-autoplay-expected.txt: Added.
* webrtc/getUserMedia-webaudio-autoplay.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225784 => 225785)


--- trunk/LayoutTests/ChangeLog	2017-12-12 16:51:54 UTC (rev 225784)
+++ trunk/LayoutTests/ChangeLog	2017-12-12 17:26:34 UTC (rev 225785)
@@ -1,3 +1,13 @@
+2017-12-12  Youenn Fablet  <[email protected]>
+
+        Allow AudioContext to start when getUserMedia is on
+        https://bugs.webkit.org/show_bug.cgi?id=180680
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/getUserMedia-webaudio-autoplay-expected.txt: Added.
+        * webrtc/getUserMedia-webaudio-autoplay.html: Added.
+
 2017-12-12  Ms2ger  <[email protected]>
 
         [WPE] Enable some wpt tests.

Added: trunk/LayoutTests/webrtc/getUserMedia-webaudio-autoplay-expected.txt (0 => 225785)


--- trunk/LayoutTests/webrtc/getUserMedia-webaudio-autoplay-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/getUserMedia-webaudio-autoplay-expected.txt	2017-12-12 17:26:34 UTC (rev 225785)
@@ -0,0 +1,6 @@
+
+PASS Ensuring autoplay does not work when starting an audio node and getUserMedia is off 
+PASS Ensuring autoplay works when resuming audio context and getUserMedia is off 
+PASS Ensuring autoplay works when starting an audio node and getUserMedia is on 
+PASS Ensuring autoplay works when resuming audio context and getUserMedia is on 
+

Added: trunk/LayoutTests/webrtc/getUserMedia-webaudio-autoplay.html (0 => 225785)


--- trunk/LayoutTests/webrtc/getUserMedia-webaudio-autoplay.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/getUserMedia-webaudio-autoplay.html	2017-12-12 17:26:34 UTC (rev 225785)
@@ -0,0 +1,73 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing webaudio autoplay in case of camera capture</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <script>
+test(() => {
+    assert_true(!!window.internals, "Test requires internals API");
+
+    var context = new webkitAudioContext();
+    internals.setAudioContextRestrictions(context, 'RequireUserGestureForAudioStart');
+
+    var node = context.createBufferSource();
+    node.connect(context.destination);
+    node.start();
+}, "Ensuring autoplay does not work when starting an audio node and getUserMedia is off");
+
+promise_test((test) => {
+    if (!window.internals)
+        return Promise.reject("Test requires internals API");
+
+    var context = new webkitAudioContext();
+    internals.setAudioContextRestrictions(context, 'RequireUserGestureForAudioStart');
+
+    var node = context.createBufferSource();
+    node.connect(context.destination);
+
+    var resolve, reject;
+    var promise = new Promise((res, rej) => {
+        resolve = res;
+        reject = rej;
+    });
+    context.resume().then(() => {
+        reject("context should not have resumed");
+    });
+    setTimeout(() => {
+        resolve();
+    }, 50);
+    return promise;
+}, "Ensuring autoplay works when resuming audio context and getUserMedia is off");
+
+promise_test((test) => {
+    if (!window.internals)
+        return Promise.reject("Test requires internals API");
+    return navigator.mediaDevices.getUserMedia({audio: true}).then((stream) => {
+        var context = new webkitAudioContext();
+        internals.setAudioContextRestrictions(context, 'RequireUserGestureForAudioStart');
+
+        var node = context.createBufferSource();
+        node.connect(context.destination);
+        node.start();
+    });
+}, "Ensuring autoplay works when starting an audio node and getUserMedia is on");
+
+promise_test((test) => {
+    if (!window.internals)
+        return Promise.reject("Test requires internals API");
+    return navigator.mediaDevices.getUserMedia({audio: true}).then((stream) => {
+        var context = new webkitAudioContext();
+        internals.setAudioContextRestrictions(context, 'RequireUserGestureForAudioStart');
+
+        var node = context.createBufferSource();
+        node.connect(context.destination);
+        return context.resume();
+    });
+}, "Ensuring autoplay works when resuming audio context and getUserMedia is on");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (225784 => 225785)


--- trunk/Source/WebCore/ChangeLog	2017-12-12 16:51:54 UTC (rev 225784)
+++ trunk/Source/WebCore/ChangeLog	2017-12-12 17:26:34 UTC (rev 225785)
@@ -1,3 +1,15 @@
+2017-12-12  Youenn Fablet  <[email protected]>
+
+        Allow AudioContext to start when getUserMedia is on
+        https://bugs.webkit.org/show_bug.cgi?id=180680
+
+        Reviewed by Eric Carlson.
+
+        Test: webrtc/getUserMedia-webaudio-autoplay.html
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::willBeginPlayback):
+
 2017-12-12  Romain Bellessort  <[email protected]>
 
         [Readable Streams API] Throw RangeError if a size is provided when creating a readable byte stream

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (225784 => 225785)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2017-12-12 16:51:54 UTC (rev 225784)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2017-12-12 17:26:34 UTC (rev 225785)
@@ -984,7 +984,7 @@
 bool AudioContext::willBeginPlayback()
 {
     if (userGestureRequiredForAudioStart()) {
-        if (!processingUserGestureForMedia())
+        if (!processingUserGestureForMedia() && !document()->isCapturing())
             return false;
         removeBehaviorRestriction(AudioContext::RequireUserGestureForAudioStartRestriction);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to