Title: [263025] trunk/Source/WebCore
Revision
263025
Author
[email protected]
Date
2020-06-15 02:13:08 -0700 (Mon, 15 Jun 2020)

Log Message

Add a quirk to allow starting AudioContext if document was interacted
https://bugs.webkit.org/show_bug.cgi?id=213118

Reviewed by Eric Carlson.

Manually tested on bing.com.

* Modules/webaudio/AudioContext.cpp:
(WebCore::isDocumentAllowingAutoplayWebAudio):
(WebCore::AudioContext::willBeginPlayback):
* page/Quirks.cpp:
(WebCore::Quirks::shouldAutoplayWebAudioForArbitraryUserGesture const):
* page/Quirks.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (263024 => 263025)


--- trunk/Source/WebCore/ChangeLog	2020-06-15 09:09:04 UTC (rev 263024)
+++ trunk/Source/WebCore/ChangeLog	2020-06-15 09:13:08 UTC (rev 263025)
@@ -1,3 +1,19 @@
+2020-06-15  Youenn Fablet  <[email protected]>
+
+        Add a quirk to allow starting AudioContext if document was interacted
+        https://bugs.webkit.org/show_bug.cgi?id=213118
+
+        Reviewed by Eric Carlson.
+
+        Manually tested on bing.com.
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::isDocumentAllowingAutoplayWebAudio):
+        (WebCore::AudioContext::willBeginPlayback):
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldAutoplayWebAudioForArbitraryUserGesture const):
+        * page/Quirks.h:
+
 2020-06-15  Tetsuharu Ohzeki  <[email protected]>
 
         Move textFromUTF8() to TextResourceDecoder from FetchBodyConsumer

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (263024 => 263025)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-06-15 09:09:04 UTC (rev 263024)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-06-15 09:13:08 UTC (rev 263025)
@@ -1086,6 +1086,13 @@
         startRendering();
 }
 
+static bool shouldDocumentAllowWebAudioToAutoPlay(const Document& document)
+{
+    if (document.processingUserGestureForMedia() || document.isCapturing())
+        return true;
+    return document.quirks().shouldAutoplayWebAudioForArbitraryUserGesture() && document.topDocument().hasHadUserInteraction();
+}
+
 bool AudioContext::willBeginPlayback()
 {
     auto* document = this->document();
@@ -1093,7 +1100,7 @@
         return false;
 
     if (userGestureRequiredForAudioStart()) {
-        if (!document->processingUserGestureForMedia() && !document->isCapturing()) {
+        if (!shouldDocumentAllowWebAudioToAutoPlay(*document)) {
             ALWAYS_LOG(LOGIDENTIFIER, "returning false, not processing user gesture or capturing");
             return false;
         }

Modified: trunk/Source/WebCore/page/Quirks.cpp (263024 => 263025)


--- trunk/Source/WebCore/page/Quirks.cpp	2020-06-15 09:09:04 UTC (rev 263024)
+++ trunk/Source/WebCore/page/Quirks.cpp	2020-06-15 09:13:08 UTC (rev 263025)
@@ -130,6 +130,15 @@
 #endif
 }
 
+bool Quirks::shouldAutoplayWebAudioForArbitraryUserGesture() const
+{
+    if (!needsQuirks())
+        return false;
+
+    auto host = m_document->topDocument().url().host();
+    return equalLettersIgnoringASCIICase(host, "www.bing.com");
+}
+
 bool Quirks::hasBrokenEncryptedMediaAPISupportQuirk() const
 {
     if (!needsQuirks())

Modified: trunk/Source/WebCore/page/Quirks.h (263024 => 263025)


--- trunk/Source/WebCore/page/Quirks.h	2020-06-15 09:09:04 UTC (rev 263024)
+++ trunk/Source/WebCore/page/Quirks.h	2020-06-15 09:13:08 UTC (rev 263025)
@@ -49,6 +49,7 @@
     bool needsSeekingSupportDisabled() const;
     bool needsPerDocumentAutoplayBehavior() const;
     bool shouldAutoplayForArbitraryUserGesture() const;
+    bool shouldAutoplayWebAudioForArbitraryUserGesture() const;
     bool hasBrokenEncryptedMediaAPISupportQuirk() const;
     bool shouldStripQuotationMarkInFontFaceSetFamily() const;
 #if ENABLE(TOUCH_EVENTS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to