Title: [214239] trunk
Revision
214239
Author
mra...@apple.com
Date
2017-03-21 18:44:21 -0700 (Tue, 21 Mar 2017)

Log Message

Loosen audio playback restrictions when the volume is 0.
https://bugs.webkit.org/show_bug.cgi?id=169897

Reviewed by Eric Carlson.

Source/WebCore:

Added API tests.

* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::playbackPermitted):

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/autoplay-zero-volume-check.html: Added.
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (214238 => 214239)


--- trunk/Source/WebCore/ChangeLog	2017-03-22 00:45:15 UTC (rev 214238)
+++ trunk/Source/WebCore/ChangeLog	2017-03-22 01:44:21 UTC (rev 214239)
@@ -1,3 +1,15 @@
+2017-03-20  Matt Rajca  <mra...@apple.com>
+
+        Loosen audio playback restrictions when the volume is 0.
+        https://bugs.webkit.org/show_bug.cgi?id=169897
+
+        Reviewed by Eric Carlson.
+
+        Added API tests.
+
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::playbackPermitted):
+
 2017-03-21  Brady Eidson  <beid...@apple.com>
 
         Disable all virtual tables.

Modified: trunk/Source/WebCore/html/MediaElementSession.cpp (214238 => 214239)


--- trunk/Source/WebCore/html/MediaElementSession.cpp	2017-03-22 00:45:15 UTC (rev 214238)
+++ trunk/Source/WebCore/html/MediaElementSession.cpp	2017-03-22 01:44:21 UTC (rev 214239)
@@ -169,7 +169,7 @@
         return MediaPlaybackDenialReason::UserGestureRequired;
     }
 
-    if (m_restrictions & RequireUserGestureForAudioRateChange && (!element.isVideo() || element.hasAudio()) && !element.muted() && !ScriptController::processingUserGestureForMedia()) {
+    if (m_restrictions & RequireUserGestureForAudioRateChange && (!element.isVideo() || element.hasAudio()) && !element.muted() && element.volume() && !ScriptController::processingUserGestureForMedia()) {
         LOG(Media, "MediaElementSession::playbackPermitted - returning FALSE because of audio rate change restriction");
         return MediaPlaybackDenialReason::UserGestureRequired;
     }

Modified: trunk/Tools/ChangeLog (214238 => 214239)


--- trunk/Tools/ChangeLog	2017-03-22 00:45:15 UTC (rev 214238)
+++ trunk/Tools/ChangeLog	2017-03-22 01:44:21 UTC (rev 214239)
@@ -1,3 +1,15 @@
+2017-03-20  Matt Rajca  <mra...@apple.com>
+
+        Loosen audio playback restrictions when the volume is 0.
+        https://bugs.webkit.org/show_bug.cgi?id=169897
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/autoplay-zero-volume-check.html: Added.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
+        (TEST):
+
 2017-03-21  Aakash Jain  <aakash_j...@apple.com>
 
         EWS fails to parse_bug_id_from_attachment_page after bugzilla upgrade

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (214238 => 214239)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-03-22 00:45:15 UTC (rev 214238)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-03-22 01:44:21 UTC (rev 214239)
@@ -537,6 +537,7 @@
 		C99B675C1E39721A00FC6C80 /* autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */; };
 		C99B675D1E39722000FC6C80 /* js-play-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */; };
 		C99B675F1E39736F00FC6C80 /* no-autoplay-with-controls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */; };
+		C99BDF891E80980400C7170E /* autoplay-zero-volume-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */; };
 		C9C60E651E53A9DC006DA181 /* autoplay-check-frame.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */; };
 		C9C60E661E53A9DC006DA181 /* autoplay-check-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */; };
 		CD321B041E3A85FA00EB21C8 /* video-with-muted-audio-and-webaudio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */; };
@@ -653,6 +654,7 @@
 			dstPath = TestWebKitAPI.resources;
 			dstSubfolderSpec = 7;
 			files = (
+				C99BDF891E80980400C7170E /* autoplay-zero-volume-check.html in Copy Resources */,
 				A14AAB651E78DC5400C1ADC2 /* encrypted.pdf in Copy Resources */,
 				A1409AD91E7254D4004949D9 /* password-protected.pages in Copy Resources */,
 				5120C83E1E67678F0025B250 /* WebsiteDataStoreCustomPaths.html in Copy Resources */,
@@ -1368,6 +1370,7 @@
 		C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-with-controls.html"; sourceTree = "<group>"; };
 		C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "js-play-with-controls.html"; sourceTree = "<group>"; };
 		C99B675E1E39735C00FC6C80 /* no-autoplay-with-controls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "no-autoplay-with-controls.html"; sourceTree = "<group>"; };
+		C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-zero-volume-check.html"; sourceTree = "<group>"; };
 		C9C60E631E53A9BA006DA181 /* autoplay-check-frame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check-frame.html"; sourceTree = "<group>"; };
 		C9C60E641E53A9BA006DA181 /* autoplay-check-in-iframe.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autoplay-check-in-iframe.html"; sourceTree = "<group>"; };
 		CD225C071C45A69200140761 /* ParsedContentRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentRange.cpp; sourceTree = "<group>"; };
@@ -2122,6 +2125,7 @@
 				C95984F21E36BC55002C0D45 /* autoplay-check.html */,
 				C95984F31E36BC55002C0D45 /* autoplay-no-audio-check.html */,
 				C99B675A1E3971FC00FC6C80 /* autoplay-with-controls.html */,
+				C99BDF881E8097E300C7170E /* autoplay-zero-volume-check.html */,
 				7C486BA01AA1254B003F6F9B /* bundle-file.html */,
 				9BD4239B1E04BFD000200395 /* chinese-character-with-image.html */,
 				1A50AA1F1A2A4EA500F4C345 /* close-from-within-create-page.html */,
@@ -2144,8 +2148,8 @@
 				BCBD372E125ABBE600D2C29F /* icon.png */,
 				CE3524F51B142BBB0028A7C5 /* input-focus-blur.html */,
 				C99B675B1E3971FC00FC6C80 /* js-play-with-controls.html */,
+				8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */,
 				8349D3C31DB9724F004A9F65 /* link-with-download-attribute.html */,
-				8361F1771E610B2100759B25 /* link-with-download-attribute-with-slashes.html */,
 				378E647816326FDF00B6C676 /* link-with-title.html */,
 				9361002814DC957B0061379D /* lots-of-iframes.html */,
 				93AF4ECF1506F123007FD57E /* lots-of-images.html */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-zero-volume-check.html (0 => 214239)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-zero-volume-check.html	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/autoplay-zero-volume-check.html	2017-03-22 01:44:21 UTC (rev 214239)
@@ -0,0 +1,22 @@
+<html>
+    <head>
+        <script>
+            function pageLoaded() {
+                var video = document.getElementById("video");
+                video.volume = 0;
+                video.play().then(function() {
+                    try {
+                        window.webkit.messageHandlers.testHandler.postMessage("autoplayed");
+                    } catch(e) { }
+                }).catch(function() {
+                    try {
+                        window.webkit.messageHandlers.testHandler.postMessage("did-not-play");
+                    } catch(e) { }
+                });
+            }
+        </script>
+    </head>
+    <body _onload_="pageLoaded()">
+        <video id="video" playsinline src="" />
+    </body>
+</html>

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm (214238 => 214239)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-03-22 00:45:15 UTC (rev 214238)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-03-22 01:44:21 UTC (rev 214239)
@@ -214,6 +214,7 @@
 
     NSURLRequest *requestWithAudio = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-check" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
     NSURLRequest *requestWithoutAudio = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-no-audio-check" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    NSURLRequest *requestWithoutVolume = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-zero-volume-check" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
     
     [delegate setAutoplayPolicyForURL:^(NSURL *) {
         return _WKWebsiteAutoplayPolicyAllowWithoutSound;
@@ -224,9 +225,15 @@
     [webView loadRequest:requestWithoutAudio];
     [webView waitForMessage:@"autoplayed"];
 
+    [webView loadRequest:requestWithoutVolume];
+    [webView waitForMessage:@"autoplayed"];
+
     [delegate setAutoplayPolicyForURL:^(NSURL *) {
         return _WKWebsiteAutoplayPolicyDeny;
     }];
+    [webView loadRequest:requestWithoutVolume];
+    [webView waitForMessage:@"did-not-play"];
+
     [webView loadRequest:requestWithAudio];
     [webView waitForMessage:@"did-not-play"];
 
@@ -249,6 +256,9 @@
     [webView loadRequest:requestWithoutAudio];
     [webView waitForMessage:@"autoplayed"];
 
+    [webView loadRequest:requestWithoutVolume];
+    [webView waitForMessage:@"autoplayed"];
+
     NSURLRequest *requestWithAudioInIFrame = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"autoplay-check-in-iframe" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
 
     // If the top-level document allows autoplay, any iframes should also autoplay.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to