Modified: branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp (251724 => 251725)
--- branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2019-10-29 19:51:17 UTC (rev 251724)
+++ branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp 2019-10-29 19:51:20 UTC (rev 251725)
@@ -464,12 +464,12 @@
return state;
}
-void MediaStreamTrack::muteCapture()
+void MediaStreamTrack::pageMutedStateDidChange(MediaProducer::MutedStateFlags flags)
{
if (auto* source = RealtimeMediaSourceCenter::singleton().audioCaptureFactory().activeSource())
- source->setMuted(true);
+ source->setMuted((flags & MediaProducer::AudioAndVideoCaptureIsMuted) || (flags & MediaProducer::AudioIsMuted));
if (auto* source = RealtimeMediaSourceCenter::singleton().videoCaptureFactory().activeSource())
- source->setMuted(true);
+ source->setMuted(flags & MediaProducer::AudioAndVideoCaptureIsMuted);
}
#endif
Modified: branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.h (251724 => 251725)
--- branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-10-29 19:51:17 UTC (rev 251724)
+++ branches/safari-608-branch/Source/WebCore/Modules/mediastream/MediaStreamTrack.h 2019-10-29 19:51:20 UTC (rev 251725)
@@ -70,7 +70,7 @@
#if PLATFORM(IOS_FAMILY)
static MediaProducer::MediaStateFlags captureState();
- static void muteCapture();
+ static void pageMutedStateDidChange(MediaProducer::MutedStateFlags);
#endif
virtual bool isCanvas() const { return false; }
Modified: branches/safari-608-branch/Source/WebCore/dom/Document.cpp (251724 => 251725)
--- branches/safari-608-branch/Source/WebCore/dom/Document.cpp 2019-10-29 19:51:17 UTC (rev 251724)
+++ branches/safari-608-branch/Source/WebCore/dom/Document.cpp 2019-10-29 19:51:20 UTC (rev 251725)
@@ -4031,7 +4031,7 @@
audioProducer.pageMutedStateDidChange();
#if ENABLE(MEDIA_STREAM) && PLATFORM(IOS_FAMILY)
- MediaStreamTrack::muteCapture();
+ MediaStreamTrack::pageMutedStateDidChange(page()->mutedState());
#endif
}
Modified: branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (251724 => 251725)
--- branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-10-29 19:51:17 UTC (rev 251724)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2019-10-29 19:51:20 UTC (rev 251725)
@@ -203,6 +203,7 @@
4135FB852011FABF00332139 /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 4135FB862011FABF00332139 /* libWebCoreTestSupport.dylib */; };
414AD6862285D1C000777F2D /* StorageQuota.mm in Sources */ = {isa = PBXBuildFile; fileRef = 414AD6852285D1B000777F2D /* StorageQuota.mm */; };
41882F0321010C0D002FF288 /* ProcessPreWarming.mm in Sources */ = {isa = PBXBuildFile; fileRef = 41882F0221010A70002FF288 /* ProcessPreWarming.mm */; };
+ 419BA4A2235A120A00BD45AF /* GetUserMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = 419BA4A1235A120500BD45AF /* GetUserMedia.mm */; };
44077BB123144B5000179E2D /* DataDetectorsTestIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44077BB0231449D200179E2D /* DataDetectorsTestIOS.mm */; };
4433A396208044140091ED57 /* SynchronousTimeoutTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */; };
44817A2F1F0486BF00003810 /* WKRequestActivatedElementInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 44817A2E1F0486BF00003810 /* WKRequestActivatedElementInfo.mm */; };
@@ -1683,6 +1684,7 @@
414AD6852285D1B000777F2D /* StorageQuota.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = StorageQuota.mm; sourceTree = "<group>"; };
41882F0221010A70002FF288 /* ProcessPreWarming.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessPreWarming.mm; sourceTree = "<group>"; };
41973B5C1AF22875006C7B36 /* SharedBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBuffer.cpp; sourceTree = "<group>"; };
+ 419BA4A1235A120500BD45AF /* GetUserMedia.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetUserMedia.mm; sourceTree = "<group>"; };
44077BB0231449D200179E2D /* DataDetectorsTestIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataDetectorsTestIOS.mm; sourceTree = "<group>"; };
442BBF681C91CAD90017087F /* RefLogger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefLogger.cpp; sourceTree = "<group>"; };
4433A395208044130091ED57 /* SynchronousTimeoutTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SynchronousTimeoutTests.mm; sourceTree = "<group>"; };
@@ -3476,6 +3478,7 @@
26F52EAA182872600023D412 /* Geolocation.cpp */,
F660AA0C15A5F061003A1243 /* GetInjectedBundleInitializationUserDataCallback.cpp */,
F660AA0F15A5F624003A1243 /* GetInjectedBundleInitializationUserDataCallback_Bundle.cpp */,
+ 419BA4A1235A120500BD45AF /* GetUserMedia.mm */,
07CE1CF21F06A7E000BF89F5 /* GetUserMediaNavigation.mm */,
07E499901F9E56A1002F1EF3 /* GetUserMediaReprompt.mm */,
4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */,
@@ -4773,6 +4776,7 @@
52D673EE1AFB127300FA19FE /* WKPageCopySessionStateWithFiltering.cpp in Sources */,
7CCE7F1F1A411AE600447C4C /* WKPageGetScaleFactorNotZero.cpp in Sources */,
7CCE7F201A411AE600447C4C /* WKPageIsPlayingAudio.cpp in Sources */,
+ 419BA4A2235A120A00BD45AF /* GetUserMedia.mm in Sources */,
A14AAB631E78D7DE00C1ADC2 /* WKPDFView.mm in Sources */,
2D00065F1C1F589A0088E6A7 /* WKPDFViewResizeCrash.mm in Sources */,
2D21FE591F04642900B58E7D /* WKPDFViewStablePresentationUpdateCallback.mm in Sources */,
Added: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm (0 => 251725)
--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm (rev 0)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm 2019-10-29 19:51:20 UTC (rev 251725)
@@ -0,0 +1,163 @@
+/*
+ * 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"
+
+#if ENABLE(MEDIA_STREAM)
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKPreferencesPrivate.h>
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKUIDelegatePrivate.h>
+#import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewConfiguration.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+
+static bool done;
+
+@interface GetUserMediaCaptureUIDelegate : NSObject<WKUIDelegate>
+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler;
+- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler;
+@end
+
+@implementation GetUserMediaCaptureUIDelegate
+- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization: (_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL))decisionHandler
+{
+ decisionHandler(YES);
+}
+
+- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler
+{
+ decisionHandler(@"0x9876543210", YES);
+}
+@end
+
+@interface GUMMessageHandler : NSObject <WKScriptMessageHandler>
+@end
+
+@implementation GUMMessageHandler
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+ EXPECT_WK_STREQ(@"PASS", [message body]);
+ done = true;
+}
+@end
+
+namespace TestWebKitAPI {
+
+void waitUntilCaptureState(WKWebView *webView, _WKMediaCaptureState expectedState)
+{
+ do {
+ auto state = [webView _mediaCaptureState];
+ if (state == expectedState)
+ return;
+ TestWebKitAPI::Util::spinRunLoop(1);
+ } while (true);
+}
+
+TEST(WebKit2, CaptureMute)
+{
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ auto processPoolConfig = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ auto preferences = [configuration preferences];
+ preferences._mediaCaptureRequiresSecureConnection = NO;
+ preferences._mediaDevicesEnabled = YES;
+ preferences._mockCaptureDevicesEnabled = YES;
+ auto webView = [[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get() processPoolConfiguration:processPoolConfig.get()];
+ auto delegate = adoptNS([[GetUserMediaCaptureUIDelegate alloc] init]);
+ webView.UIDelegate = delegate.get();
+
+ [webView loadTestPageNamed:@"getUserMedia"];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateActiveCamera);
+
+ [webView _setPageMuted: _WKMediaCaptureDevicesMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateMutedCamera);
+ [webView _setPageMuted: _WKMediaNoneMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateActiveCamera);
+
+ [webView stringByEvaluatingJavaScript:@"stop()"];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateNone);
+
+ [webView stringByEvaluatingJavaScript:@"captureAudio()"];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateActiveMicrophone);
+ [webView _setPageMuted: _WKMediaCaptureDevicesMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateMutedMicrophone);
+ [webView _setPageMuted: _WKMediaNoneMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateActiveMicrophone);
+
+ [webView _setPageMuted: _WKMediaCaptureDevicesMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateMutedMicrophone);
+
+ [webView stringByEvaluatingJavaScript:@"stop()"];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateNone);
+
+ [webView stringByEvaluatingJavaScript:@"captureAudioAndVideo()"];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateActiveCamera | _WKMediaCaptureStateActiveMicrophone);
+ [webView _setPageMuted: _WKMediaCaptureDevicesMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateMutedCamera | _WKMediaCaptureStateMutedMicrophone);
+ [webView _setPageMuted: _WKMediaNoneMuted];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateActiveCamera | _WKMediaCaptureStateActiveMicrophone);
+
+ [webView stringByEvaluatingJavaScript:@"stop()"];
+ waitUntilCaptureState(webView, _WKMediaCaptureStateNone);
+}
+
+#if WK_HAVE_C_SPI
+TEST(WebKit, WebAudioAndGetUserMedia)
+{
+ done = false;
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ auto context = adoptWK(TestWebKitAPI::Util::createContextForInjectedBundleTest("InternalsInjectedBundleTest"));
+ configuration.get().processPool = (WKProcessPool *)context.get();
+ configuration.get().processPool._configuration.shouldCaptureAudioInUIProcess = NO;
+
+ auto preferences = [configuration preferences];
+ preferences._mediaCaptureRequiresSecureConnection = NO;
+ preferences._mediaDevicesEnabled = YES;
+ preferences._mockCaptureDevicesEnabled = YES;
+
+ auto messageHandler = adoptNS([[GUMMessageHandler alloc] init]);
+ [[configuration.get() userContentController] addScriptMessageHandler:messageHandler.get() name:@"gum"];
+
+ auto webView = [[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500) configuration:configuration.get()];
+
+ auto delegate = adoptNS([[GetUserMediaCaptureUIDelegate alloc] init]);
+ webView.UIDelegate = delegate.get();
+
+ auto url = "" "html"));
+ [webView loadTestPageNamed:@"getUserMedia-webaudio"];
+
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+#endif
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(MEDIA_STREAM)