Title: [230158] trunk
Revision
230158
Author
jer.no...@apple.com
Date
2018-04-02 08:40:20 -0700 (Mon, 02 Apr 2018)

Log Message

AudioBufferSourceNode start method causes OfflineAudioContext to start running
https://bugs.webkit.org/show_bug.cgi?id=181939
<rdar://problem/36755393>

Reviewed by Eric Carlson.

Source/WebCore:

Test: webaudio/offlineaudiocontext-restriction.html

Don't respect playback restrictions for offline AudioContexts.

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon):
* Modules/webaudio/AudioContext.h:
(WebCore::AudioContext::isOfflineContext const):
(WebCore::AudioContext::userGestureRequiredForAudioStart const):
(WebCore::AudioContext::pageConsentRequiredForAudioStart const):
(WebCore::AudioContext::isOfflineContext): Deleted.

LayoutTests:

* webaudio/offlineaudiocontext-restriction-expected.txt: Added.
* webaudio/offlineaudiocontext-restriction.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230157 => 230158)


--- trunk/LayoutTests/ChangeLog	2018-04-02 14:55:48 UTC (rev 230157)
+++ trunk/LayoutTests/ChangeLog	2018-04-02 15:40:20 UTC (rev 230158)
@@ -1,3 +1,14 @@
+2018-04-02  Jer Noble  <jer.no...@apple.com>
+
+        AudioBufferSourceNode start method causes OfflineAudioContext to start running
+        https://bugs.webkit.org/show_bug.cgi?id=181939
+        <rdar://problem/36755393>
+
+        Reviewed by Eric Carlson.
+
+        * webaudio/offlineaudiocontext-restriction-expected.txt: Added.
+        * webaudio/offlineaudiocontext-restriction.html: Added.
+
 2018-03-31  Brent Fulgham  <bfulg...@apple.com>
 
         Show punycode if URL contains hyphen character

Added: trunk/LayoutTests/webaudio/offlineaudiocontext-restriction-expected.txt (0 => 230158)


--- trunk/LayoutTests/webaudio/offlineaudiocontext-restriction-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webaudio/offlineaudiocontext-restriction-expected.txt	2018-04-02 15:40:20 UTC (rev 230158)
@@ -0,0 +1,14 @@
+OfflineAudioContexts should not have behavior restrictions.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS context.state is "suspended"
+node.connect(context.destination)
+node.start()
+PASS context.state is "suspended"
+Calling context.startRendering() without a user gesture
+PASS context.state is "running"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webaudio/offlineaudiocontext-restriction.html (0 => 230158)


--- trunk/LayoutTests/webaudio/offlineaudiocontext-restriction.html	                        (rev 0)
+++ trunk/LayoutTests/webaudio/offlineaudiocontext-restriction.html	2018-04-02 15:40:20 UTC (rev 230158)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src=""
+<script type="text/_javascript_" src=""
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description('OfflineAudioContexts should not have behavior restrictions.');
+
+var context = null;
+var node = null;
+var calledResumeWithUserGesture = false;
+
+function runTest() {
+    window.jsTestIsAsync = true;
+
+    context = new webkitOfflineAudioContext(2, 1000, 44100);
+
+    if (window.internals)
+        internals.setAudioContextRestrictions(context, 'RequireUserGestureForAudioStart');
+
+    shouldBe('context.state', '"suspended"');
+
+    node = context.createBufferSource();
+    evalAndLog('node.connect(context.destination)');
+    evalAndLog('node.start()');
+    shouldBe('context.state', '"suspended"');
+
+    debug('Calling context.startRendering() without a user gesture');
+    context.startRendering();
+    shouldBe('context.state', '"running"');
+    finishJSTest();
+}
+
+runTest();
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (230157 => 230158)


--- trunk/Source/WebCore/ChangeLog	2018-04-02 14:55:48 UTC (rev 230157)
+++ trunk/Source/WebCore/ChangeLog	2018-04-02 15:40:20 UTC (rev 230158)
@@ -1,3 +1,23 @@
+2018-04-02  Jer Noble  <jer.no...@apple.com>
+
+        AudioBufferSourceNode start method causes OfflineAudioContext to start running
+        https://bugs.webkit.org/show_bug.cgi?id=181939
+        <rdar://problem/36755393>
+
+        Reviewed by Eric Carlson.
+
+        Test: webaudio/offlineaudiocontext-restriction.html
+
+        Don't respect playback restrictions for offline AudioContexts.
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::constructCommon):
+        * Modules/webaudio/AudioContext.h:
+        (WebCore::AudioContext::isOfflineContext const):
+        (WebCore::AudioContext::userGestureRequiredForAudioStart const):
+        (WebCore::AudioContext::pageConsentRequiredForAudioStart const):
+        (WebCore::AudioContext::isOfflineContext): Deleted.
+
 2018-04-02  Alejandro G. Castro  <a...@igalia.com>
 
         [GTK] Make libwebrtc backend buildable for GTK  port

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (230157 => 230158)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2018-04-02 14:55:48 UTC (rev 230157)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2018-04-02 15:40:20 UTC (rev 230158)
@@ -166,12 +166,10 @@
     
     m_listener = AudioListener::create();
 
-#if PLATFORM(IOS)
-    if (document()->settings().audioPlaybackRequiresUserGesture())
+    if (document()->audioPlaybackRequiresUserGesture())
         addBehaviorRestriction(RequireUserGestureForAudioStartRestriction);
     else
         m_restrictions = NoRestrictions;
-#endif
 
 #if PLATFORM(COCOA)
     addBehaviorRestriction(RequirePageConsentForAudioStartRestriction);

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (230157 => 230158)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2018-04-02 14:55:48 UTC (rev 230157)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2018-04-02 15:40:20 UTC (rev 230158)
@@ -85,7 +85,7 @@
 
     bool isInitialized() const;
     
-    bool isOfflineContext() { return m_isOfflineContext; }
+    bool isOfflineContext() const { return m_isOfflineContext; }
 
     Document* document() const; // ASSERTs if document no longer exists.
 
@@ -276,8 +276,8 @@
     bool willBeginPlayback();
     bool willPausePlayback();
 
-    bool userGestureRequiredForAudioStart() const { return m_restrictions & RequireUserGestureForAudioStartRestriction; }
-    bool pageConsentRequiredForAudioStart() const { return m_restrictions & RequirePageConsentForAudioStartRestriction; }
+    bool userGestureRequiredForAudioStart() const { return !isOfflineContext() && m_restrictions & RequireUserGestureForAudioStartRestriction; }
+    bool pageConsentRequiredForAudioStart() const { return !isOfflineContext() && m_restrictions & RequirePageConsentForAudioStartRestriction; }
 
     void setState(State);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to