Title: [269192] branches/safari-611.1.4-branch
Revision
269192
Author
[email protected]
Date
2020-10-30 10:42:22 -0700 (Fri, 30 Oct 2020)

Log Message

Cherry-pick r268878. rdar://problem/70831133

    UIClient isn't notified when page muted state changes
    https://bugs.webkit.org/show_bug.cgi?id=218085
    <rdar://problem/70462420>

    Reviewed by Youenn Fablet.

    Source/WebKit:

    API test: WKWebView.MediaMuted

    * UIProcess/API/C/WKPage.cpp:
    (WKPageGetMediaState): reportedMediaCaptureState -> reportedMediaState.

    * UIProcess/API/Cocoa/WKWebView.mm:
    (-[WKWebView _mediaCaptureState]): Ditto.

    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::updateReportedMediaCaptureState): Only record current capture
    state in m_reportedMediaCaptureState. m_delayStopCapturingReporting isn't necessary,
    remove it.

    * UIProcess/WebPageProxy.h:
    (WebKit::WebPageProxy::reportedMediaState const): Renamed from reportedMediaCaptureState
    to reflect what it returns.
    (WebKit::WebPageProxy::mediaStateFlags const): Deleted.
    (WebKit::WebPageProxy::reportedMediaCaptureState const): Deleted.

    Tools:

    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme:
    * TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm: Added.
    (-[AudioStateObserver initWithWebView:]):
    (-[AudioStateObserver observeValueForKeyPath:ofObject:change:context:]):
    (-[AudioStateTestView setMuted:]):
    (TestWebKitAPI::TEST):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268878 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-611.1.4-branch/Source/WebKit/ChangeLog (269191 => 269192)


--- branches/safari-611.1.4-branch/Source/WebKit/ChangeLog	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Source/WebKit/ChangeLog	2020-10-30 17:42:22 UTC (rev 269192)
@@ -1,5 +1,76 @@
 2020-10-29  Alan Coon  <[email protected]>
 
+        Cherry-pick r268878. rdar://problem/70831133
+
+    UIClient isn't notified when page muted state changes
+    https://bugs.webkit.org/show_bug.cgi?id=218085
+    <rdar://problem/70462420>
+    
+    Reviewed by Youenn Fablet.
+    
+    Source/WebKit:
+    
+    API test: WKWebView.MediaMuted
+    
+    * UIProcess/API/C/WKPage.cpp:
+    (WKPageGetMediaState): reportedMediaCaptureState -> reportedMediaState.
+    
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView _mediaCaptureState]): Ditto.
+    
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::updateReportedMediaCaptureState): Only record current capture
+    state in m_reportedMediaCaptureState. m_delayStopCapturingReporting isn't necessary,
+    remove it.
+    
+    * UIProcess/WebPageProxy.h:
+    (WebKit::WebPageProxy::reportedMediaState const): Renamed from reportedMediaCaptureState
+    to reflect what it returns.
+    (WebKit::WebPageProxy::mediaStateFlags const): Deleted.
+    (WebKit::WebPageProxy::reportedMediaCaptureState const): Deleted.
+    
+    Tools:
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme:
+    * TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm: Added.
+    (-[AudioStateObserver initWithWebView:]):
+    (-[AudioStateObserver observeValueForKeyPath:ofObject:change:context:]):
+    (-[AudioStateTestView setMuted:]):
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-10-22  Eric Carlson  <[email protected]>
+
+            UIClient isn't notified when page muted state changes
+            https://bugs.webkit.org/show_bug.cgi?id=218085
+            <rdar://problem/70462420>
+
+            Reviewed by Youenn Fablet.
+
+            API test: WKWebView.MediaMuted
+
+            * UIProcess/API/C/WKPage.cpp:
+            (WKPageGetMediaState): reportedMediaCaptureState -> reportedMediaState.
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _mediaCaptureState]): Ditto.
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::updateReportedMediaCaptureState): Only record current capture
+            state in m_reportedMediaCaptureState. m_delayStopCapturingReporting isn't necessary,
+            remove it.
+
+            * UIProcess/WebPageProxy.h:
+            (WebKit::WebPageProxy::reportedMediaState const): Renamed from reportedMediaCaptureState
+            to reflect what it returns.
+            (WebKit::WebPageProxy::mediaStateFlags const): Deleted.
+            (WebKit::WebPageProxy::reportedMediaCaptureState const): Deleted.
+
+2020-10-29  Alan Coon  <[email protected]>
+
         Cherry-pick r268386. rdar://problem/70831174
 
     Cocoa: Make WebGLLayer not dependent on  GraphicsContextGLOpenGL

Modified: branches/safari-611.1.4-branch/Source/WebKit/UIProcess/API/C/WKPage.cpp (269191 => 269192)


--- branches/safari-611.1.4-branch/Source/WebKit/UIProcess/API/C/WKPage.cpp	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Source/WebKit/UIProcess/API/C/WKPage.cpp	2020-10-30 17:42:22 UTC (rev 269192)
@@ -2819,7 +2819,7 @@
 
 WKMediaState WKPageGetMediaState(WKPageRef page)
 {
-    WebCore::MediaProducer::MediaStateFlags coreState = toImpl(page)->reportedMediaCaptureState();
+    WebCore::MediaProducer::MediaStateFlags coreState = toImpl(page)->reportedMediaState();
     WKMediaState state = kWKMediaIsNotPlaying;
 
     if (coreState & WebCore::MediaProducer::IsPlayingAudio)

Modified: branches/safari-611.1.4-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (269191 => 269192)


--- branches/safari-611.1.4-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2020-10-30 17:42:22 UTC (rev 269192)
@@ -3021,7 +3021,7 @@
 
 - (_WKMediaCaptureState)_mediaCaptureState
 {
-    return WebKit::toWKMediaCaptureState(_page->reportedMediaCaptureState());
+    return WebKit::toWKMediaCaptureState(_page->reportedMediaState());
 }
 
 - (void)_setMediaCaptureEnabled:(BOOL)enabled

Modified: branches/safari-611.1.4-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (269191 => 269192)


--- branches/safari-611.1.4-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-10-30 17:42:22 UTC (rev 269192)
@@ -8950,24 +8950,23 @@
 
 void WebPageProxy::updateReportedMediaCaptureState()
 {
-    if (m_reportedMediaCaptureState == m_mediaState)
+    auto activeCaptureState = m_mediaState & MediaProducer::MediaCaptureMask;
+    if (m_reportedMediaCaptureState == activeCaptureState)
         return;
 
     bool haveReportedCapture = m_reportedMediaCaptureState & MediaProducer::MediaCaptureMask;
-    bool willReportCapture = m_mediaState & MediaProducer::MediaCaptureMask;
+    bool willReportCapture = activeCaptureState;
 
     if (haveReportedCapture && !willReportCapture && m_delayStopCapturingReportingTimer.isActive())
         return;
 
     if (!haveReportedCapture && willReportCapture) {
-        m_delayStopCapturingReporting = true;
         m_delayStopCapturingReportingTimer.doTask([this] {
-            m_delayStopCapturingReporting = false;
             updateReportedMediaCaptureState();
         }, m_mediaCaptureReportingDelay);
     }
 
-    m_reportedMediaCaptureState = m_mediaState;
+    m_reportedMediaCaptureState = activeCaptureState;
     m_uiClient->mediaCaptureStateDidChange(m_mediaState);
 }
 

Modified: branches/safari-611.1.4-branch/Source/WebKit/UIProcess/WebPageProxy.h (269191 => 269192)


--- branches/safari-611.1.4-branch/Source/WebKit/UIProcess/WebPageProxy.h	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Source/WebKit/UIProcess/WebPageProxy.h	2020-10-30 17:42:22 UTC (rev 269192)
@@ -1450,8 +1450,7 @@
     bool isCapturingVideo() const { return m_mediaState & WebCore::MediaProducer::VideoCaptureMask; }
     bool hasActiveAudioStream() const { return m_mediaState & WebCore::MediaProducer::HasActiveAudioCaptureDevice; }
     bool hasActiveVideoStream() const { return m_mediaState & WebCore::MediaProducer::HasActiveVideoCaptureDevice; }
-    WebCore::MediaProducer::MediaStateFlags mediaStateFlags() const { return m_mediaState; }
-    WebCore::MediaProducer::MediaStateFlags reportedMediaCaptureState() const { return m_reportedMediaCaptureState; }
+    WebCore::MediaProducer::MediaStateFlags reportedMediaState() const { return m_reportedMediaCaptureState | (m_mediaState & ~WebCore::MediaProducer::MediaCaptureMask); }
     WebCore::MediaProducer::MutedStateFlags mutedStateFlags() const { return m_mutedState; }
 
     void handleAutoplayEvent(WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>);
@@ -2753,7 +2752,6 @@
     // To make sure capture indicators are visible long enough, m_reportedMediaCaptureState is the same as m_mediaState except that we might delay a bit transition from capturing to not-capturing.
     WebCore::MediaProducer::MediaStateFlags m_reportedMediaCaptureState { WebCore::MediaProducer::IsNotPlaying };
     WebCore::DeferrableTaskTimer m_delayStopCapturingReportingTimer;
-    bool m_delayStopCapturingReporting { false };
     static constexpr Seconds DefaultMediaCaptureReportingDelay { 3_s };
     Seconds m_mediaCaptureReportingDelay { DefaultMediaCaptureReportingDelay };
 

Modified: branches/safari-611.1.4-branch/Tools/ChangeLog (269191 => 269192)


--- branches/safari-611.1.4-branch/Tools/ChangeLog	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Tools/ChangeLog	2020-10-30 17:42:22 UTC (rev 269192)
@@ -1,3 +1,63 @@
+2020-10-29  Alan Coon  <[email protected]>
+
+        Cherry-pick r268878. rdar://problem/70831133
+
+    UIClient isn't notified when page muted state changes
+    https://bugs.webkit.org/show_bug.cgi?id=218085
+    <rdar://problem/70462420>
+    
+    Reviewed by Youenn Fablet.
+    
+    Source/WebKit:
+    
+    API test: WKWebView.MediaMuted
+    
+    * UIProcess/API/C/WKPage.cpp:
+    (WKPageGetMediaState): reportedMediaCaptureState -> reportedMediaState.
+    
+    * UIProcess/API/Cocoa/WKWebView.mm:
+    (-[WKWebView _mediaCaptureState]): Ditto.
+    
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::updateReportedMediaCaptureState): Only record current capture
+    state in m_reportedMediaCaptureState. m_delayStopCapturingReporting isn't necessary,
+    remove it.
+    
+    * UIProcess/WebPageProxy.h:
+    (WebKit::WebPageProxy::reportedMediaState const): Renamed from reportedMediaCaptureState
+    to reflect what it returns.
+    (WebKit::WebPageProxy::mediaStateFlags const): Deleted.
+    (WebKit::WebPageProxy::reportedMediaCaptureState const): Deleted.
+    
+    Tools:
+    
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme:
+    * TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm: Added.
+    (-[AudioStateObserver initWithWebView:]):
+    (-[AudioStateObserver observeValueForKeyPath:ofObject:change:context:]):
+    (-[AudioStateTestView setMuted:]):
+    (TestWebKitAPI::TEST):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268878 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-10-22  Eric Carlson  <[email protected]>
+
+            UIClient isn't notified when page muted state changes
+            https://bugs.webkit.org/show_bug.cgi?id=218085
+            <rdar://problem/70462420>
+
+            Reviewed by Youenn Fablet.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/xcshareddata/xcschemes/TestWebKitAPI.xcscheme:
+            * TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm: Added.
+            (-[AudioStateObserver initWithWebView:]):
+            (-[AudioStateObserver observeValueForKeyPath:ofObject:change:context:]):
+            (-[AudioStateTestView setMuted:]):
+            (TestWebKitAPI::TEST):
+
 2020-10-26  Alan Coon  <[email protected]>
 
         Cherry-pick r268940. rdar://problem/70702182

Modified: branches/safari-611.1.4-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (269191 => 269192)


--- branches/safari-611.1.4-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-10-30 17:42:17 UTC (rev 269191)
+++ branches/safari-611.1.4-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2020-10-30 17:42:22 UTC (rev 269192)
@@ -64,6 +64,7 @@
 		07E1F6A21FFC44FA0096C7EC /* getDisplayMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 07E1F6A11FFC44F90096C7EC /* getDisplayMedia.html */; };
 		07E1F6A31FFC4B760096C7EC /* GetDisplayMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07E1F6A01FFC3A080096C7EC /* GetDisplayMedia.mm */; };
 		07E499911F9E56DF002F1EF3 /* GetUserMediaReprompt.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07E499901F9E56A1002F1EF3 /* GetUserMediaReprompt.mm */; };
+		07EF76D52540FC060053ED53 /* MediaMutedState.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EF76D42540FC060053ED53 /* MediaMutedState.mm */; };
 		07F4E92E20AF59E2002E3803 /* UserMediaSimulateFailedSandbox.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07F4E92D20AF58D3002E3803 /* UserMediaSimulateFailedSandbox.mm */; };
 		0E404A8C2166DE0A008271BA /* InjectedBundleNodeHandleIsSelectElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0E404A8A2166DDF8008271BA /* InjectedBundleNodeHandleIsSelectElement.mm */; };
 		0EBBCC661FFF9E0C00FA42AB /* pop-up-check.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 0EBBCC651FFF9DCE00FA42AB /* pop-up-check.html */; };
@@ -1701,6 +1702,7 @@
 		07E1F6A11FFC44F90096C7EC /* getDisplayMedia.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; name = getDisplayMedia.html; path = ../WebKit/getDisplayMedia.html; sourceTree = "<group>"; };
 		07E499901F9E56A1002F1EF3 /* GetUserMediaReprompt.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GetUserMediaReprompt.mm; sourceTree = "<group>"; };
 		07EDEFAC1EB9400C00D43292 /* UserMediaDisabled.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserMediaDisabled.mm; sourceTree = "<group>"; };
+		07EF76D42540FC060053ED53 /* MediaMutedState.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaMutedState.mm; sourceTree = "<group>"; };
 		07F4E92D20AF58D3002E3803 /* UserMediaSimulateFailedSandbox.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UserMediaSimulateFailedSandbox.mm; sourceTree = "<group>"; };
 		0BCD833414857CE400EA2003 /* HashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HashMap.cpp; sourceTree = "<group>"; };
 		0BCD85691485C98B00EA2003 /* SetForScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetForScope.cpp; sourceTree = "<group>"; };
@@ -3292,6 +3294,7 @@
 				07CC7DFD2266330800E39181 /* MediaBufferingPolicy.mm */,
 				95B6B3B6251EBF2F00FC4382 /* MediaDocument.mm */,
 				CD0370E224A44B7A00BA3CAE /* MediaLoading.mm */,
+				07EF76D42540FC060053ED53 /* MediaMutedState.mm */,
 				51BE9E652376089500B4E117 /* MediaType.mm */,
 				5165FE03201EE617009F7EC3 /* MessagePortProviders.mm */,
 				51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
@@ -5274,6 +5277,7 @@
 				07CC7DFE2266330900E39181 /* MediaBufferingPolicy.mm in Sources */,
 				95B6B3B7251EBF2F00FC4382 /* MediaDocument.mm in Sources */,
 				CD0370E324A44D9600BA3CAE /* MediaLoading.mm in Sources */,
+				07EF76D52540FC060053ED53 /* MediaMutedState.mm in Sources */,
 				CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */,
 				CDC9442E1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm in Sources */,
 				51BE9E662376089F00B4E117 /* MediaType.mm in Sources */,

Added: branches/safari-611.1.4-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm (0 => 269192)


--- branches/safari-611.1.4-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm	                        (rev 0)
+++ branches/safari-611.1.4-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/MediaMutedState.mm	2020-10-30 17:42:22 UTC (rev 269192)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2020 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 PLATFORM(MAC)
+
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import <WebKit/WKMediaPlaybackState.h>
+#import <WebKit/WKWebView.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+static void *audioStateObserverChangeKVOContext = &audioStateObserverChangeKVOContext;
+static bool stateDidChange;
+
+@interface AudioStateObserver : NSObject
+- (instancetype)initWithWebView:(TestWKWebView *)webView;
+@property (nonatomic, readonly) BOOL isPlayingAudio;
+@end
+
+@implementation AudioStateObserver {
+    RetainPtr<TestWKWebView> _webView;
+}
+
+- (instancetype)initWithWebView:(TestWKWebView *)webView
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _webView = webView;
+    [webView addObserver:self forKeyPath:@"_isPlayingAudio" options:NSKeyValueObservingOptionNew context:audioStateObserverChangeKVOContext];
+    return self;
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+    if (context == audioStateObserverChangeKVOContext) {
+        stateDidChange = true;
+        return;
+    }
+
+    [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
+}
+@end
+
+@interface AudioStateTestView : TestWKWebView
+- (BOOL)setMuted:(_WKMediaMutedState)expected;
+@end
+
+@implementation AudioStateTestView
+- (BOOL)setMuted:(_WKMediaMutedState)state
+{
+    [self _setPageMuted:state];
+
+    int retryCount = 100;
+    while (retryCount--) {
+        if ([self _mediaMutedState] == state)
+            return YES;
+
+        TestWebKitAPI::Util::spinRunLoop(10);
+    }
+
+    return NO;
+}
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WKWebView, MediaMuted)
+{
+    auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    auto webView = adoptNS([[AudioStateTestView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:configuration.get() addToWindow:YES]);
+    auto observer = adoptNS([[AudioStateObserver alloc] initWithWebView:webView.get()]);
+
+    [webView synchronouslyLoadHTMLString:@"<video src="" webkit-playsinline loop></video>"];
+
+    EXPECT_EQ([webView _mediaMutedState], _WKMediaNoneMuted);
+
+    stateDidChange = false;
+    [webView evaluateJavaScript:@"document.querySelector('video').play()" completionHandler:nil];
+    TestWebKitAPI::Util::run(&stateDidChange);
+
+    EXPECT_EQ([webView _mediaMutedState], _WKMediaNoneMuted);
+
+    [webView setMuted:_WKMediaAudioMuted];
+    EXPECT_EQ([webView _mediaMutedState], _WKMediaAudioMuted);
+
+    [webView setMuted:_WKMediaNoneMuted];
+    EXPECT_EQ([webView _mediaMutedState], _WKMediaNoneMuted);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to