Diff
Modified: trunk/Source/WebKit/ChangeLog (246135 => 246136)
--- trunk/Source/WebKit/ChangeLog 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Source/WebKit/ChangeLog 2019-06-06 01:22:18 UTC (rev 246136)
@@ -1,3 +1,25 @@
+2019-06-05 Jer Noble <jer.no...@apple.com>
+
+ -[WKWebView _suspendAllMediaPlayback] does not persist across navigation.
+ https://bugs.webkit.org/show_bug.cgi?id=198585
+
+ Reviewed by Chris Dumez.
+
+ Add a new WebPageCreationParameters entry for mediaPlaybackIsSuspended, and pass
+ that value across during WebPage creation.
+
+ * Shared/WebPageCreationParameters.cpp:
+ (WebKit::WebPageCreationParameters::encode const):
+ (WebKit::WebPageCreationParameters::decode):
+ * Shared/WebPageCreationParameters.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::suspendAllMediaPlayback):
+ (WebKit::WebPageProxy::resumeAllMediaPlayback):
+ (WebKit::WebPageProxy::creationParameters):
+ * UIProcess/WebPageProxy.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage):
+
2019-06-05 Sihui Liu <sihui_...@apple.com>
TestWebKitAPI.WKWebView.LocalStorageProcessSuspends is flaky on release builds
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (246135 => 246136)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp 2019-06-06 01:22:18 UTC (rev 246136)
@@ -66,6 +66,7 @@
encoder << mediaVolume;
encoder << muted;
encoder << mayStartMediaWhenInWindow;
+ encoder << mediaPlaybackIsSuspended;
encoder << viewLayoutSize;
encoder << autoSizingShouldExpandToViewHeight;
encoder << viewportSizeForCSSViewportUnits;
@@ -223,6 +224,8 @@
return WTF::nullopt;
if (!decoder.decode(parameters.mayStartMediaWhenInWindow))
return WTF::nullopt;
+ if (!decoder.decode(parameters.mediaPlaybackIsSuspended))
+ return WTF::nullopt;
if (!decoder.decode(parameters.viewLayoutSize))
return WTF::nullopt;
if (!decoder.decode(parameters.autoSizingShouldExpandToViewHeight))
Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (246135 => 246136)
--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h 2019-06-06 01:22:18 UTC (rev 246136)
@@ -116,6 +116,7 @@
float mediaVolume;
WebCore::MediaProducer::MutedStateFlags muted;
bool mayStartMediaWhenInWindow;
+ bool mediaPlaybackIsSuspended { false };
WebCore::IntSize viewLayoutSize;
bool autoSizingShouldExpandToViewHeight;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (246135 => 246136)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2019-06-06 01:22:18 UTC (rev 246136)
@@ -5472,6 +5472,10 @@
void WebPageProxy::suspendAllMediaPlayback()
{
+ if (m_mediaPlaybackIsSuspended)
+ return;
+ m_mediaPlaybackIsSuspended = true;
+
if (!hasRunningProcess())
return;
@@ -5480,6 +5484,10 @@
void WebPageProxy::resumeAllMediaPlayback()
{
+ if (!m_mediaPlaybackIsSuspended)
+ return;
+ m_mediaPlaybackIsSuspended = false;
+
if (!hasRunningProcess())
return;
@@ -7125,6 +7133,7 @@
parameters.mediaVolume = m_mediaVolume;
parameters.muted = m_mutedState;
parameters.mayStartMediaWhenInWindow = m_mayStartMediaWhenInWindow;
+ parameters.mediaPlaybackIsSuspended = m_mediaPlaybackIsSuspended;
parameters.viewLayoutSize = m_viewLayoutSize;
parameters.autoSizingShouldExpandToViewHeight = m_autoSizingShouldExpandToViewHeight;
parameters.viewportSizeForCSSViewportUnits = m_viewportSizeForCSSViewportUnits;
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (246135 => 246136)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2019-06-06 01:22:18 UTC (rev 246136)
@@ -2412,6 +2412,7 @@
float m_mediaVolume { 1 };
WebCore::MediaProducer::MutedStateFlags m_mutedState { WebCore::MediaProducer::NoneMuted };
bool m_mayStartMediaWhenInWindow { true };
+ bool m_mediaPlaybackIsSuspended { false };
bool m_mediaCaptureEnabled { true };
bool m_waitingForDidUpdateActivityState { false };
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (246135 => 246136)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2019-06-06 01:22:18 UTC (rev 246136)
@@ -539,6 +539,8 @@
m_page->setCanStartMedia(false);
m_mayStartMediaWhenInWindow = parameters.mayStartMediaWhenInWindow;
+ if (parameters.mediaPlaybackIsSuspended)
+ m_page->suspendAllMediaPlayback();
m_page->setGroupName(m_pageGroup->identifier());
m_page->setDeviceScaleFactor(parameters.deviceScaleFactor);
Modified: trunk/Tools/ChangeLog (246135 => 246136)
--- trunk/Tools/ChangeLog 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Tools/ChangeLog 2019-06-06 01:22:18 UTC (rev 246136)
@@ -1,3 +1,16 @@
+2019-06-05 Jer Noble <jer.no...@apple.com>
+
+ -[WKWebView _suspendAllMediaPlayback] does not persist across navigation.
+ https://bugs.webkit.org/show_bug.cgi?id=198585
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm: Added.
+ (TEST):
+ * TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html:
+
2019-06-05 Alex Christensen <achristen...@webkit.org>
Re-enable safe browsing in WKWebView
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (246135 => 246136)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-06-06 01:22:18 UTC (rev 246136)
@@ -825,6 +825,7 @@
CD758A6F20572EA00071834A /* video-with-paused-audio-and-playing-muted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD758A6E20572D540071834A /* video-with-paused-audio-and-playing-muted.html */; };
CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */; };
CD78E11E1DB7EE2A0014A2DE /* FullscreenDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */; };
+ CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */; };
CD9E292E1C90C33F000BB800 /* audio-only.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CD9E292D1C90C1BA000BB800 /* audio-only.html */; };
CDA29B2920FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */; };
CDA29B2B20FD358400F15CED /* ExitFullscreenOnEnterPiP.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDA29B2A20FD344E00F15CED /* ExitFullscreenOnEnterPiP.html */; };
@@ -2210,6 +2211,7 @@
CD773F711C5057DB0002257C /* FeatureDefines.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FeatureDefines.xcconfig; sourceTree = "<group>"; };
CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FullscreenDelegate.mm; sourceTree = "<group>"; };
CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenDelegate.html; sourceTree = "<group>"; };
+ CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewSuspendAllMediaPlayback.mm; sourceTree = "<group>"; };
CD89D0381C4EDB2A00040A04 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; };
CD9E292B1C90A71F000BB800 /* RequiresUserActionForPlayback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RequiresUserActionForPlayback.mm; sourceTree = "<group>"; };
CD9E292D1C90C1BA000BB800 /* audio-only.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "audio-only.html"; sourceTree = "<group>"; };
@@ -2789,6 +2791,7 @@
D3BE5E341E4CE85E00FD563A /* WKWebViewGetContents.mm */,
37A9DBE7213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm */,
93F56DA81E5F9181003EDE84 /* WKWebViewSnapshot.mm */,
+ CD7F89DB22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm */,
9984FACA1CFFAEEE008D198C /* WKWebViewTextInput.mm */,
);
name = "WebKit Cocoa";
@@ -4559,6 +4562,7 @@
F4FA91811E61849B007B8C1D /* WKWebViewMacEditingTests.mm in Sources */,
37A9DBE9213B4C9300D261A2 /* WKWebViewServerTrustKVC.mm in Sources */,
93F56DA91E5F919D003EDE84 /* WKWebViewSnapshot.mm in Sources */,
+ CD7F89DC22A86CDA00D683AE /* WKWebViewSuspendAllMediaPlayback.mm in Sources */,
9984FACC1CFFAF60008D198C /* WKWebViewTextInput.mm in Sources */,
9C64DC321D76198A004B598E /* YouTubePluginReplacement.cpp in Sources */,
);
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (246135 => 246136)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm 2019-06-06 01:22:18 UTC (rev 246136)
@@ -6265,3 +6265,33 @@
}
#endif
+
+TEST(ProcessSwap, SuspendAllMediaPlayback)
+{
+ auto processPoolConfiguration = psonProcessPoolConfiguration();
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+#if TARGET_OS_IPHONE
+ configuration.get().allowsInlineMediaPlayback = YES;
+#endif
+ [configuration setProcessPool:processPool.get()];
+ auto handler = adoptNS([[PSONScheme alloc] init]);
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ __block bool loaded = false;
+ [webView performAfterLoading:^{ loaded = true; }];
+ [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]]];
+
+ TestWebKitAPI::Util::run(&loaded);
+
+ [webView _suspendAllMediaPlayback];
+
+ __block bool notPlaying = false;
+ [webView performAfterReceivingMessage:@"not playing" action:^() { notPlaying = true; }];
+ [webView synchronouslyLoadTestPageNamed:@"video-with-audio"];
+ TestWebKitAPI::Util::run(¬Playing);
+}
Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm (0 => 246136)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewSuspendAllMediaPlayback.mm 2019-06-06 01:22:18 UTC (rev 246136)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/WKWebViewPrivate.h>
+
+TEST(WKWebViewSuspendAllMediaPlayback, BeforeLoading)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+#if TARGET_OS_IPHONE
+ configuration.get().allowsInlineMediaPlayback = YES;
+#endif
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]);
+ [webView _suspendAllMediaPlayback];
+
+ __block bool notPlaying = false;
+ [webView performAfterReceivingMessage:@"not playing" action:^{ notPlaying = true; }];
+ [webView synchronouslyLoadTestPageNamed:@"video-with-audio"];
+ TestWebKitAPI::Util::run(¬Playing);
+}
+
+
+TEST(WKWebViewSuspendAllMediaPlayback, AfterLoading)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+#if TARGET_OS_IPHONE
+ configuration.get().allowsInlineMediaPlayback = YES;
+#endif
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]);
+
+ __block bool isPlaying = false;
+ [webView performAfterReceivingMessage:@"playing" action:^{ isPlaying = true; }];
+
+ [webView synchronouslyLoadTestPageNamed:@"video-with-audio"];
+
+ TestWebKitAPI::Util::run(&isPlaying);
+
+ __block bool isPaused = false;
+ [webView performAfterReceivingMessage:@"paused" action:^{ isPaused = true; }];
+ [webView stringByEvaluatingJavaScript:@"document.querySelector('video').addEventListener('pause', paused);"];
+ [webView _suspendAllMediaPlayback];
+
+ TestWebKitAPI::Util::run(&isPaused);
+
+ isPlaying = false;
+ [webView performAfterReceivingMessage:@"playing" action:^{ isPlaying = true; }];
+ [webView stringByEvaluatingJavaScript:@"document.querySelector('video').addEventListener('playing', playing);"];
+ [webView _resumeAllMediaPlayback];
+
+ TestWebKitAPI::Util::run(&isPlaying);
+}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html (246135 => 246136)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html 2019-06-06 00:46:25 UTC (rev 246135)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitLegacy/ios/video-with-audio.html 2019-06-06 01:22:18 UTC (rev 246136)
@@ -17,6 +17,12 @@
}
}
+ function paused() {
+ try {
+ window.webkit.messageHandlers.testHandler.postMessage('paused');
+ } catch(e) { }
+ }
+
function notPlaying() {
try {
window.webkit.messageHandlers.testHandler.postMessage('not playing');