Title: [211103] branches/safari-603-branch
Revision
211103
Author
[email protected]
Date
2017-01-24 13:22:50 -0800 (Tue, 24 Jan 2017)

Log Message

Merge r211045. rdar://problem/29486368

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (211102 => 211103)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1,5 +1,30 @@
 2017-01-24  Matthew Hanson  <[email protected]>
 
+        Merge r211045. rdar://problem/29486368
+
+    2017-01-23  Jer Noble  <[email protected]>
+
+            REGRESSION (r208149): Video details does not apear and missing scrubber in Control Center
+            https://bugs.webkit.org/show_bug.cgi?id=167233
+
+            Reviewed by Alex Christensen.
+
+            Test: In TestWebKitAPI, NowPlayingControlsTests.NowPlayingControlsIOS
+
+            In r208149, we introduced a new media type, Video, and renamed the old type to
+            VideoAudio (to be able to distinguish between video-with-audio and silent-video).
+            But we missed one place where that type needs to be renamed.
+
+            For testing purposes, overload methods from PlatformMediaSessionManager which WebKit2 uses
+            to report the current now playing session and it's information.
+
+            * platform/audio/ios/MediaSessionManagerIOS.h:
+            * platform/audio/ios/MediaSessionManagerIOS.mm:
+            (WebCore::MediaSessionManageriOS::nowPlayingEligibleSession):
+            (WebCore::MediaSessionManageriOS::updateNowPlayingInfo):
+
+2017-01-24  Matthew Hanson  <[email protected]>
+
         Merge r211028. rdar://problem/30060378
 
     2017-01-20  Dean Jackson  <[email protected]>

Modified: branches/safari-603-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (211102 => 211103)


--- branches/safari-603-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -70,11 +70,17 @@
 
     bool sessionCanLoadMedia(const PlatformMediaSession&) const override;
 
+    bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
+    String lastUpdatedNowPlayingTitle() const final { return m_reportedTitle; }
+    double lastUpdatedNowPlayingDuration() const final { return m_reportedDuration; }
+    double lastUpdatedNowPlayingElapsedTime() const final { return m_reportedCurrentTime; }
+
     PlatformMediaSession* nowPlayingEligibleSession();
     
     RetainPtr<WebMediaSessionHelper> m_objcObserver;
     double m_reportedRate { 0 };
     double m_reportedDuration { 0 };
+    double m_reportedCurrentTime { 0 };
     String m_reportedTitle;
     bool m_nowPlayingActive { false };
     bool m_isInBackground { false };

Modified: branches/safari-603-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (211102 => 211103)


--- branches/safari-603-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -219,7 +219,7 @@
 {
     return findSession([] (PlatformMediaSession& session, size_t) {
         PlatformMediaSession::MediaType type = session.mediaType();
-        if (type != PlatformMediaSession::Video && type != PlatformMediaSession::Audio)
+        if (type != PlatformMediaSession::VideoAudio && type != PlatformMediaSession::Audio)
             return false;
 
         if (session.characteristics() & PlatformMediaSession::HasAudio)
@@ -249,6 +249,7 @@
     String title = currentSession->title();
     double duration = currentSession->duration();
     double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0;
+    double currentTime = currentSession->currentTime();
     if (m_reportedTitle == title && m_reportedRate == rate && m_reportedDuration == duration) {
         LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - nothing new to show");
         return;
@@ -257,6 +258,7 @@
     m_reportedRate = rate;
     m_reportedDuration = duration;
     m_reportedTitle = title;
+    m_reportedCurrentTime = currentTime;
 
     auto info = adoptNS([[NSMutableDictionary alloc] init]);
     if (!title.isEmpty())
@@ -265,7 +267,6 @@
         info.get()[MPMediaItemPropertyPlaybackDuration] = @(duration);
     info.get()[MPNowPlayingInfoPropertyPlaybackRate] = @(rate);
 
-    double currentTime = currentSession->currentTime();
     if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime())
         info.get()[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(currentTime);
 

Modified: branches/safari-603-branch/Source/WebKit2/ChangeLog (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1,5 +1,39 @@
 2017-01-24  Matthew Hanson  <[email protected]>
 
+        Merge r211045. rdar://problem/29486368
+
+    2017-01-23  Jer Noble  <[email protected]>
+
+            Video details does not apear and missing scrubber in Control Center
+            https://bugs.webkit.org/show_bug.cgi?id=167233
+
+            Reviewed by Alex Christensen.
+
+            Make requestActiveNowPlayingSessionInfo() and handleActiveNowPlayingSessionInfoResponse()
+            work in PLATFORM(IOS).
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _requestActiveNowPlayingSessionInfo]):
+            (-[WKWebView _handleActiveNowPlayingSessionInfoResponse:title:duration:elapsedTime:]):
+            * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+            * UIProcess/PageClient.h:
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::requestActiveNowPlayingSessionInfo):
+            (WebKit::WebPageProxy::handleActiveNowPlayingSessionInfoResponse):
+            * UIProcess/WebPageProxy.h:
+            * UIProcess/WebPageProxy.messages.in:
+            * UIProcess/ios/PageClientImplIOS.h:
+            * UIProcess/ios/PageClientImplIOS.mm:
+            (WebKit::PageClientImpl::handleActiveNowPlayingSessionInfoResponse):
+            * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
+            (WebKit::WebPage::requestActiveNowPlayingSessionInfo):
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::requestActiveNowPlayingSessionInfo): Deleted.
+
+2017-01-24  Matthew Hanson  <[email protected]>
+
         Merge r211007. rdar://problem/28620919
 
     2017-01-20  Brady Eidson  <[email protected]>

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -4861,17 +4861,6 @@
     return _impl->shouldRequestCandidates();
 }
 
-- (void)_requestActiveNowPlayingSessionInfo
-{
-    if (_page)
-        _page->requestActiveNowPlayingSessionInfo();
-}
-
-- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime
-{
-    // Overridden by subclasses.
-}
-
 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange
 {
     [self insertText:string replacementRange:replacementRange];
@@ -4889,6 +4878,17 @@
 
 #endif // PLATFORM(MAC)
 
+- (void)_requestActiveNowPlayingSessionInfo
+{
+    if (_page)
+        _page->requestActiveNowPlayingSessionInfo();
+}
+
+- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime
+{
+    // Overridden by subclasses.
+}
+
 - (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin
 {
     _page->scalePage(scale, WebCore::roundedIntPoint(origin));

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -308,9 +308,6 @@
 - (void)_forceRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 - (void)_didUpdateCandidateListVisibility:(BOOL)visible WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 @property (nonatomic, readonly) BOOL _shouldRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
-- (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA));
-- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA));
-
 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 
 - (void)_setHeaderBannerHeight:(int)height WK_API_AVAILABLE(macosx(WK_MAC_TBA));
@@ -317,6 +314,9 @@
 - (void)_setFooterBannerHeight:(int)height WK_API_AVAILABLE(macosx(WK_MAC_TBA));
 #endif
 
+- (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 - (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (CGFloat)_pageScale WK_API_AVAILABLE(ios(WK_IOS_TBA));
 

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/PageClient.h (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/PageClient.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/PageClient.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -253,7 +253,6 @@
     virtual void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) = 0;
     virtual void removeNavigationGestureSnapshot() = 0;
     virtual void handleControlledElementIDResponse(const String&) = 0;
-    virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) = 0;
 
     virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
 
@@ -284,6 +283,10 @@
     virtual void setEditableElementIsFocused(bool) = 0;
 #endif // PLATFORM(MAC)
 
+#if PLATFORM(COCOA)
+    virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) = 0;
+#endif
+
 #if PLATFORM(IOS)
     virtual void commitPotentialTapFailed() = 0;
     virtual void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color&, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) = 0;

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-01-24 21:22:50 UTC (rev 211103)
@@ -6468,16 +6468,6 @@
 #endif
 }
 
-void WebPageProxy::requestActiveNowPlayingSessionInfo()
-{
-    m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), m_pageID);
-}
-
-void WebPageProxy::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const
-{
-    m_pageClient.handleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime);
-}
-
 void WebPageProxy::handleControlledElementIDResponse(const String& identifier) const
 {
     m_pageClient.handleControlledElementIDResponse(identifier);
@@ -6493,6 +6483,18 @@
 }
 #endif
 
+#if PLATFORM(COCOA)
+void WebPageProxy::requestActiveNowPlayingSessionInfo()
+{
+    m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), m_pageID);
+}
+
+void WebPageProxy::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const
+{
+    m_pageClient.handleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime);
+}
+#endif
+
 #if ENABLE(MEDIA_SESSION)
 void WebPageProxy::hasMediaSessionWithActiveMediaElementsDidChange(bool state)
 {

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.h (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1064,9 +1064,12 @@
     bool hasActiveVideoForControlsManager() const;
     void requestControlledElementID() const;
     void handleControlledElementIDResponse(const String&) const;
+    bool isPlayingVideoInEnhancedFullscreen() const;
+#endif
+
+#if PLATFORM(COCOA)
     void requestActiveNowPlayingSessionInfo();
     void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const;
-    bool isPlayingVideoInEnhancedFullscreen() const;
 #endif
 
 #if ENABLE(MEDIA_SESSION)

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/WebPageProxy.messages.in	2017-01-24 21:22:50 UTC (rev 211103)
@@ -483,6 +483,9 @@
 
 #if PLATFORM(MAC)
     DidHandleAcceptedCandidate()
+#endif
+
+#if PLATFORM(COCOA)
     HandleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, String title, double duration, double elapsedTime)
 #endif
 

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -194,6 +194,8 @@
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
 
+    void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
+
     WKContentView *m_contentView;
     WKWebView *m_webView;
     RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;

Modified: branches/safari-603-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -34,6 +34,7 @@
 #import "InteractionInformationAtPosition.h"
 #import "NativeWebKeyboardEvent.h"
 #import "NavigationState.h"
+#import "StringUtilities.h"
 #import "UIKitSPI.h"
 #import "ViewSnapshotStore.h"
 #import "WKContentView.h"
@@ -749,6 +750,11 @@
     return ValidationBubble::create(m_contentView, message);
 }
 
+void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
+{
+    [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/Cocoa/WebPageCocoa.mm (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/Cocoa/WebPageCocoa.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -27,6 +27,8 @@
 #import "WebPage.h"
 
 #import "LoadParameters.h"
+#import "WebPageProxyMessages.h"
+#import <WebCore/PlatformMediaSessionManager.h>
 
 #if PLATFORM(COCOA)
 
@@ -39,6 +41,22 @@
     m_dataDetectionContext = loadParameters.dataDetectionContext;
 }
 
+void WebPage::requestActiveNowPlayingSessionInfo()
+{
+    bool hasActiveSession = false;
+    String title = emptyString();
+    double duration = NAN;
+    double elapsedTime = NAN;
+    if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists()) {
+        hasActiveSession = sharedManager->hasActiveNowPlayingSession();
+        title = sharedManager->lastUpdatedNowPlayingTitle();
+        duration = sharedManager->lastUpdatedNowPlayingDuration();
+        elapsedTime = sharedManager->lastUpdatedNowPlayingElapsedTime();
+    }
+
+    send(Messages::WebPageProxy::HandleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime));
+}
+
 } // namespace WebKit
 
 #endif // PLATFORM(COCOA)

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1221,6 +1221,9 @@
     void dataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID);
 
     void handleAcceptedCandidate(WebCore::TextCheckingResult);
+#endif
+
+#if PLATFORM(COCOA)
     void requestActiveNowPlayingSessionInfo();
 #endif
 

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in	2017-01-24 21:22:50 UTC (rev 211103)
@@ -422,12 +422,15 @@
     DataDetectorsDidHideUI(WebCore::PageOverlay::PageOverlayID pageOverlay)
 
     HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
-    RequestActiveNowPlayingSessionInfo()
 
     SetHeaderBannerHeightForTesting(int height);
     SetFooterBannerHeightForTesting(int height);
 #endif
 
+#if PLATFORM(COCOA)
+    RequestActiveNowPlayingSessionInfo()
+#endif
+
     SetShouldDispatchFakeMouseMoveEvents(bool shouldDispatchFakeMouseMoveEvents)
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)

Modified: branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (211102 => 211103)


--- branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -76,7 +76,6 @@
 #import <WebCore/Page.h>
 #import <WebCore/PageOverlayController.h>
 #import <WebCore/PlatformKeyboardEvent.h>
-#import <WebCore/PlatformMediaSessionManager.h>
 #import <WebCore/PluginDocument.h>
 #import <WebCore/RenderElement.h>
 #import <WebCore/RenderObject.h>
@@ -162,22 +161,6 @@
     send(Messages::WebPageProxy::DidHandleAcceptedCandidate());
 }
 
-void WebPage::requestActiveNowPlayingSessionInfo()
-{
-    bool hasActiveSession = false;
-    String title = emptyString();
-    double duration = NAN;
-    double elapsedTime = NAN;
-    if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists()) {
-        hasActiveSession = sharedManager->hasActiveNowPlayingSession();
-        title = sharedManager->lastUpdatedNowPlayingTitle();
-        duration = sharedManager->lastUpdatedNowPlayingDuration();
-        elapsedTime = sharedManager->lastUpdatedNowPlayingElapsedTime();
-    }
-
-    send(Messages::WebPageProxy::HandleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime));
-}
-
 NSObject *WebPage::accessibilityObjectForMainFramePlugin()
 {
     if (!m_page)

Modified: branches/safari-603-branch/Tools/ChangeLog (211102 => 211103)


--- branches/safari-603-branch/Tools/ChangeLog	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/ChangeLog	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1,3 +1,46 @@
+2017-01-24  Matthew Hanson  <[email protected]>
+
+        Merge r211045. rdar://problem/29486368
+
+    2017-01-23  Jer Noble  <[email protected]>
+
+            Video details does not apear and missing scrubber in Control Center
+            https://bugs.webkit.org/show_bug.cgi?id=167233
+
+            Reviewed by Alex Christensen.
+
+            Refactor TestWKWebViewMac to work on PLATFORM(IOS). Add a new test to
+            NowPlayingControlTests for iOS.
+
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            * TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm:
+            (-[NowPlayingTestWebView setWindowVisible:]):
+            (TestWebKitAPI::TEST):
+            * TestWebKitAPI/Tests/WebKit2Cocoa/SnapshotStore.mm:
+            * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
+            * TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm:
+            * TestWebKitAPI/cocoa/TestWKWebView.h: Renamed from Tools/TestWebKitAPI/mac/TestWKWebViewMac.h.
+            * TestWebKitAPI/cocoa/TestWKWebView.mm: Renamed from Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm.
+            (SOFT_LINK_CLASS):
+            (-[TestMessageHandler addMessage:withHandler:]):
+            (-[TestMessageHandler userContentController:didReceiveScriptMessage:]):
+            (__simulated_forceClickAssociatedEventsMask):
+            (-[TestWKWebViewHostWindow _mouseDownAtPoint:simulatePressure:]):
+            (-[TestWKWebViewHostWindow isKeyWindow]):
+            (-[TestWKWebViewHostWindow makeKeyWindow]):
+            (-[TestWKWebViewHostWindow resignKeyWindow]):
+            (-[TestWKWebView initWithFrame:]):
+            (-[TestWKWebView initWithFrame:configuration:]):
+            (-[TestWKWebView _setUpTestWindow:]):
+            (-[TestWKWebView performAfterReceivingMessage:action:]):
+            (-[TestWKWebView loadTestPageNamed:]):
+            (-[TestWKWebView synchronouslyLoadTestPageNamed:]):
+            (-[TestWKWebView stringByEvaluatingJavaScript:]):
+            (-[TestWKWebView waitForMessage:]):
+            (-[TestWKWebView performAfterLoading:]):
+            (-[TestWKWebView mouseDownAtPoint:simulatePressure:]):
+            (-[TestWKWebView typeCharacter:]):
+
 2017-01-20  Matthew Hanson  <[email protected]>
 
         Merge r210949. rdar://problem/30108531

Modified: branches/safari-603-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2017-01-24 21:22:50 UTC (rev 211103)
@@ -86,7 +86,7 @@
 		2EFF06C51D8867760004BB30 /* change-video-source-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */; };
 		2EFF06C71D886A580004BB30 /* change-video-source-on-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */; };
 		2EFF06CD1D8A429A0004BB30 /* input-field-in-scrollable-document.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */; };
-		2EFF06D41D8AEDBB0004BB30 /* TestWKWebViewMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D31D8AEDBB0004BB30 /* TestWKWebViewMac.mm */; };
+		2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */; };
 		2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */; };
 		315118101DB1AE4000176304 /* ExtendedColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3151180F1DB1ADD500176304 /* ExtendedColor.cpp */; };
 		33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
@@ -875,8 +875,8 @@
 		2EFF06C41D8867700004BB30 /* change-video-source-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-click.html"; sourceTree = "<group>"; };
 		2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-end.html"; sourceTree = "<group>"; };
 		2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "input-field-in-scrollable-document.html"; sourceTree = "<group>"; };
-		2EFF06D21D8AEDBB0004BB30 /* TestWKWebViewMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestWKWebViewMac.h; sourceTree = "<group>"; };
-		2EFF06D31D8AEDBB0004BB30 /* TestWKWebViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestWKWebViewMac.mm; sourceTree = "<group>"; };
+		2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestWKWebView.h; path = cocoa/TestWKWebView.h; sourceTree = "<group>"; };
+		2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestWKWebView.mm; path = cocoa/TestWKWebView.mm; sourceTree = "<group>"; };
 		2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCandidateTests.mm; sourceTree = "<group>"; };
 		3151180F1DB1ADD500176304 /* ExtendedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendedColor.cpp; sourceTree = "<group>"; };
 		333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
@@ -1423,6 +1423,8 @@
 				2D1C04A61D76298B000A6816 /* TestNavigationDelegate.mm */,
 				A14FC58D1B8AE36500D107EB /* TestProtocol.h */,
 				A14FC58E1B8AE36500D107EB /* TestProtocol.mm */,
+				2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */,
+				2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */,
 				7C83E0391D0A602700FEBCF3 /* UtilitiesCocoa.mm */,
 				A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */,
 				A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */,
@@ -1993,8 +1995,6 @@
 				C081224413FC19EC00DC39AE /* SyntheticBackingScaleFactorWindow.m */,
 				29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */,
 				29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */,
-				2EFF06D21D8AEDBB0004BB30 /* TestWKWebViewMac.h */,
-				2EFF06D31D8AEDBB0004BB30 /* TestWKWebViewMac.mm */,
 				C08587BE13FE956C001EF4E5 /* WebKitAgnosticTest.h */,
 				C08587BD13FE956C001EF4E5 /* WebKitAgnosticTest.mm */,
 			);
@@ -2548,7 +2548,7 @@
 				8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
 				7CCE7EFC1A411AE600447C4C /* InjectedBundleFrameHitTest.cpp in Sources */,
 				7CCE7EFD1A411AE600447C4C /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
-				2EFF06D41D8AEDBB0004BB30 /* TestWKWebViewMac.mm in Sources */,
+				2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */,
 				7C83E0B81D0A64BD00FEBCF3 /* InjectedBundleMakeAllShadowRootsOpen.cpp in Sources */,
 				7CCE7EC31A411A7E00447C4C /* InspectorBar.mm in Sources */,
 				7CCE7EDA1A411A8700447C4C /* InstanceMethodSwizzler.mm in Sources */,

Modified: branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -26,12 +26,12 @@
 #include "config.h"
 
 #import "PlatformUtilities.h"
-#import "TestWKWebViewMac.h"
+#import "TestWKWebView.h"
 
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>
 
-#if WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
+#if WK_API_ENABLED && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201)
 
 @interface NowPlayingTestWebView : TestWKWebView
 @property (nonatomic, readonly) BOOL hasActiveNowPlayingSession;
@@ -93,10 +93,20 @@
 
     _receivedNowPlayingInfoResponse = true;
 }
+
+- (void)setWindowVisible:(BOOL)isVisible
+{
+#if PLATFORM(MAC)
+    [self.window setIsVisible:isVisible];
+#else
+    self.window.hidden = !isVisible;
+#endif
+}
 @end
 
 namespace TestWebKitAPI {
 
+#if PLATFORM(MAC)
 TEST(NowPlayingControlsTests, NowPlayingControlsDoNotShowForForegroundPage)
 {
     WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
@@ -105,7 +115,7 @@
     [webView loadTestPageNamed:@"large-video-test-now-playing"];
     [webView waitForMessage:@"playing"];
 
-    [webView.window setIsVisible:YES];
+    [webView setWindowVisible:YES];
     [webView.window makeKeyWindow];
     [webView expectHasActiveNowPlayingSession:NO];
 
@@ -122,7 +132,7 @@
     [webView loadTestPageNamed:@"large-video-test-now-playing"];
     [webView waitForMessage:@"playing"];
 
-    [webView.window setIsVisible:NO];
+    [webView setWindowVisible:NO];
     [webView.window resignKeyWindow];
     [webView expectHasActiveNowPlayingSession:YES];
 
@@ -139,12 +149,12 @@
     [webView loadTestPageNamed:@"large-video-test-now-playing"];
     [webView waitForMessage:@"playing"];
 
-    [webView.window setIsVisible:NO];
+    [webView setWindowVisible:NO];
     [webView.window resignKeyWindow];
 
     [webView expectHasActiveNowPlayingSession:YES];
 
-    [webView.window setIsVisible:YES];
+    [webView setWindowVisible:YES];
     [webView.window makeKeyWindow];
 
     [webView expectHasActiveNowPlayingSession:NO];
@@ -162,8 +172,8 @@
     [webView loadTestPageNamed:@"large-video-test-now-playing"];
     [webView waitForMessage:@"playing"];
 
-    [webView mouseDownAtPoint:NSMakePoint(240, 160) simulatePressure:YES];
-    [webView.window setIsVisible:NO];
+    [webView stringByEvaluatingJavaScript:@"document.querySelector('video').muted = true"];
+    [webView setWindowVisible:NO];
     [webView.window resignKeyWindow];
 
     [webView waitForNowPlayingInfoToChange];
@@ -172,7 +182,24 @@
     ASSERT_TRUE(isnan(webView.lastUpdatedDuration));
     ASSERT_TRUE(isnan(webView.lastUpdatedElapsedTime));
 }
+#endif // PLATFORM(MAC)
 
+#if PLATFORM(IOS)
+TEST(NowPlayingControlsTests, NowPlayingControlsIOS)
+{
+    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
+    configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
+    NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 480, 320) configuration:configuration];
+    [webView loadTestPageNamed:@"large-video-test-now-playing"];
+    [webView waitForMessage:@"playing"];
+
+    [webView expectHasActiveNowPlayingSession:YES];
+    ASSERT_STREQ("foo", webView.lastUpdatedTitle.UTF8String);
+    ASSERT_EQ(10, webView.lastUpdatedDuration);
+    ASSERT_GE(webView.lastUpdatedElapsedTime, 0);
+}
+#endif
+
 } // namespace TestWebKitAPI
 
-#endif // WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
+#endif // WK_API_ENABLED && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201)

Modified: branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/SnapshotStore.mm (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/SnapshotStore.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/SnapshotStore.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -31,7 +31,7 @@
 #import "PlatformUtilities.h"
 #import "Test.h"
 #import "TestNavigationDelegate.h"
-#import "TestWKWebViewMac.h"
+#import "TestWKWebView.h"
 #import <WebKit/WKBackForwardListItemPrivate.h>
 #import <WebKit/WKPage.h>
 #import <WebKit/WKPagePrivate.h>

Modified: branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -26,7 +26,7 @@
 #include "config.h"
 
 #import "PlatformUtilities.h"
-#import "TestWKWebViewMac.h"
+#import "TestWKWebView.h"
 
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WKWebViewPrivate.h>

Modified: branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -28,7 +28,7 @@
 #if WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
 
 #import "PlatformUtilities.h"
-#import "TestWKWebViewMac.h"
+#import "TestWKWebView.h"
 
 #import <Carbon/Carbon.h>
 #import <WebKit/WebKitPrivate.h>

Copied: branches/safari-603-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h (from rev 211102, branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h) (0 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	                        (rev 0)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 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 <WebKit/WebKit.h>
+
+#if WK_API_ENABLED
+
+@interface TestMessageHandler : NSObject <WKScriptMessageHandler>
+- (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler;
+@end
+
+@interface TestWKWebView : WKWebView
+- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;
+- (void)loadTestPageNamed:(NSString *)pageName;
+- (void)synchronouslyLoadTestPageNamed:(NSString *)pageName;
+- (NSString *)stringByEvaluatingJavaScript:(NSString *)script;
+- (void)waitForMessage:(NSString *)message;
+- (void)performAfterLoading:(dispatch_block_t)actions;
+@end
+
+#if PLATFORM(MAC)
+@interface TestWKWebView (MacOnly)
+// Simulates clicking with a pressure-sensitive device, if possible.
+- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
+- (void)typeCharacter:(char)character;
+@end
+#endif
+
+#endif // WK_API_ENABLED
+

Copied: branches/safari-603-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm (from rev 211102, branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm) (0 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	                        (rev 0)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2016 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 "TestWKWebView.h"
+
+#if WK_API_ENABLED
+
+#import "TestNavigationDelegate.h"
+#import "Utilities.h"
+
+#import <WebKit/WebKitPrivate.h>
+#import <objc/runtime.h>
+#import <wtf/RetainPtr.h>
+
+#if PLATFORM(MAC)
+#import <AppKit/AppKit.h>
+#import <Carbon/Carbon.h>
+#import <wtf/mac/AppKitCompatibilityDeclarations.h>
+#endif
+
+#if PLATFORM(IOS)
+#import <WebCore/SoftLinking.h>
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK_CLASS(UIKit, UIWindow)
+#endif
+
+@implementation TestMessageHandler {
+    NSMutableDictionary<NSString *, dispatch_block_t> *_messageHandlers;
+}
+
+- (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler
+{
+    if (!_messageHandlers)
+        _messageHandlers = [NSMutableDictionary dictionary];
+
+    _messageHandlers[message] = [handler copy];
+}
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    dispatch_block_t handler = _messageHandlers[message.body];
+    if (handler)
+        handler();
+}
+
+@end
+
+#if PLATFORM(MAC)
+@interface TestWKWebViewHostWindow : NSWindow
+#else
+@interface TestWKWebViewHostWindow : UIWindow
+#endif // PLATFORM(MAC)
+@end
+
+@implementation TestWKWebViewHostWindow {
+    BOOL _forceKeyWindow;
+}
+
+#if PLATFORM(MAC)
+static int gEventNumber = 1;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
+NSEventMask __simulated_forceClickAssociatedEventsMask(id self, SEL _cmd)
+{
+    return NSEventMaskPressure | NSEventMaskLeftMouseDown | NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged;
+}
+#endif
+
+- (void)_mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
+{
+    NSEventType mouseEventType = NSEventTypeLeftMouseDown;
+
+    NSEventMask modifierFlags = 0;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
+    if (simulatePressure)
+        modifierFlags |= NSEventMaskPressure;
+#else
+    simulatePressure = NO;
+#endif
+
+    NSEvent *event = [NSEvent mouseEventWithType:mouseEventType location:point modifierFlags:modifierFlags timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:1 pressure:simulatePressure];
+    if (!simulatePressure) {
+        [self sendEvent:event];
+        return;
+    }
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
+    IMP simulatedAssociatedEventsMaskImpl = (IMP)__simulated_forceClickAssociatedEventsMask;
+    Method associatedEventsMaskMethod = class_getInstanceMethod([NSEvent class], @selector(associatedEventsMask));
+    IMP originalAssociatedEventsMaskImpl = method_setImplementation(associatedEventsMaskMethod, simulatedAssociatedEventsMaskImpl);
+    @try {
+        [self sendEvent:event];
+    } @finally {
+        // In the case where event sending raises an exception, we still want to restore the original implementation
+        // to prevent subsequent event sending tests from being affected.
+        method_setImplementation(associatedEventsMaskMethod, originalAssociatedEventsMaskImpl);
+    }
+#endif
+}
+#endif // PLATFORM(MAC)
+
+- (BOOL)isKeyWindow
+{
+    return _forceKeyWindow || [super isKeyWindow];
+}
+
+- (void)makeKeyWindow
+{
+    if (_forceKeyWindow)
+        return;
+
+    _forceKeyWindow = YES;
+#if PLATFORM(MAC)
+    [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidBecomeKeyNotification object:self];
+#else
+    [[NSNotificationCenter defaultCenter] postNotificationName:UIWindowDidBecomeKeyNotification object:self];
+#endif
+}
+
+- (void)resignKeyWindow
+{
+    _forceKeyWindow = NO;
+    [super resignKeyWindow];
+}
+
+@end
+
+@implementation TestWKWebView {
+    TestWKWebViewHostWindow *_hostWindow;
+    RetainPtr<TestMessageHandler> _testHandler;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame
+{
+    WKWebViewConfiguration *defaultConfiguration = [[WKWebViewConfiguration alloc] init];
+    return [self initWithFrame:frame configuration:defaultConfiguration];
+}
+
+- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
+{
+    if (self = [super initWithFrame:frame configuration:configuration])
+        [self _setUpTestWindow:frame];
+
+    return self;
+}
+
+- (void)_setUpTestWindow:(NSRect)frame
+{
+#if PLATFORM(MAC)
+    _hostWindow = [[TestWKWebViewHostWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
+    [_hostWindow setFrameOrigin:NSMakePoint(0, 0)];
+    [_hostWindow setIsVisible:YES];
+    [[_hostWindow contentView] addSubview:self];
+    [_hostWindow makeKeyAndOrderFront:self];
+#else
+    _hostWindow = [[TestWKWebViewHostWindow alloc] initWithFrame:frame];
+    _hostWindow.hidden = NO;
+    [_hostWindow addSubview:self];
+#endif
+}
+
+- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action
+{
+    if (!_testHandler) {
+        _testHandler = adoptNS([[TestMessageHandler alloc] init]);
+        [[[self configuration] userContentController] addScriptMessageHandler:_testHandler.get() name:@"testHandler"];
+    }
+
+    [_testHandler addMessage:message withHandler:action];
+}
+
+- (void)loadTestPageNamed:(NSString *)pageName
+{
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:pageName withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [self loadRequest:request];
+}
+
+- (void)synchronouslyLoadTestPageNamed:(NSString *)pageName
+{
+    [self loadTestPageNamed:pageName];
+    [self _test_waitForDidFinishNavigation];
+}
+
+- (NSString *)stringByEvaluatingJavaScript:(NSString *)script
+{
+    __block bool isWaitingForJavaScript = false;
+    __block NSString *evalResult = nil;
+    [self evaluateJavaScript:script completionHandler:^(id result, NSError *error)
+    {
+        evalResult = [NSString stringWithFormat:@"%@", result];
+        isWaitingForJavaScript = true;
+        EXPECT_TRUE(!error);
+    }];
+
+    TestWebKitAPI::Util::run(&isWaitingForJavaScript);
+    return evalResult;
+}
+
+- (void)waitForMessage:(NSString *)message
+{
+    __block bool isDoneWaiting = false;
+    [self performAfterReceivingMessage:message action:^()
+    {
+        isDoneWaiting = true;
+    }];
+    TestWebKitAPI::Util::run(&isDoneWaiting);
+}
+
+- (void)performAfterLoading:(dispatch_block_t)actions {
+    TestMessageHandler *handler = [[TestMessageHandler alloc] init];
+    [handler addMessage:@"loaded" withHandler:actions];
+
+    NSString *_onloadScript_ = @"window._onload_ = () => window.webkit.messageHandlers.onloadHandler.postMessage('loaded')";
+    WKUserScript *script = [[WKUserScript alloc] initWithSource:onloadScript injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
+
+    WKUserContentController* contentController = [[self configuration] userContentController];
+    [contentController addUserScript:script];
+    [contentController addScriptMessageHandler:handler name:@"onloadHandler"];
+}
+
+@end
+
+#if PLATFORM(MAC)
+@implementation TestWKWebView (MacOnly)
+- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
+{
+    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
+}
+
+- (void)typeCharacter:(char)character {
+    NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
+    NSEventType keyDownEventType = NSEventTypeKeyDown;
+    NSEventType keyUpEventType = NSEventTypeKeyUp;
+    [self keyDown:[NSEvent keyEventWithType:keyDownEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
+    [self keyUp:[NSEvent keyEventWithType:keyUpEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
+}
+@end
+#endif
+
+#endif // WK_API_ENABLED

Deleted: branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.h	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2016 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.
- */
-
-#ifndef TestWKWebViewMac_h
-#define TestWKWebViewMac_h
-
-#import <WebKit/WebKit.h>
-
-#if WK_API_ENABLED && PLATFORM(MAC)
-
-@interface TestMessageHandler : NSObject <WKScriptMessageHandler>
-- (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler;
-@end
-
-@interface TestWKWebView : WKWebView
-// Simulates clicking with a pressure-sensitive device, if possible.
-- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
-- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;
-- (void)loadTestPageNamed:(NSString *)pageName;
-- (void)synchronouslyLoadTestPageNamed:(NSString *)pageName;
-- (void)typeCharacter:(char)character;
-- (NSString *)stringByEvaluatingJavaScript:(NSString *)script;
-- (void)waitForMessage:(NSString *)message;
-- (void)performAfterLoading:(dispatch_block_t)actions;
-@end
-
-#endif /* WK_API_ENABLED && PLATFORM(MAC) */
-
-#endif /* TestWKWebViewMac_h */

Deleted: branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm (211102 => 211103)


--- branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm	2017-01-24 21:22:42 UTC (rev 211102)
+++ branches/safari-603-branch/Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm	2017-01-24 21:22:50 UTC (rev 211103)
@@ -1,234 +0,0 @@
-/*
- * Copyright (C) 2016 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 "TestWKWebViewMac.h"
-
-#if WK_API_ENABLED && PLATFORM(MAC)
-
-#import "TestNavigationDelegate.h"
-#import "Utilities.h"
-
-#import <AppKit/AppKit.h>
-#import <Carbon/Carbon.h>
-#import <WebKit/WebKitPrivate.h>
-#import <objc/runtime.h>
-#import <wtf/RetainPtr.h>
-#import <wtf/mac/AppKitCompatibilityDeclarations.h>
-
-@implementation TestMessageHandler {
-    NSMutableDictionary<NSString *, dispatch_block_t> *_messageHandlers;
-}
-
-- (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler
-{
-    if (!_messageHandlers)
-        _messageHandlers = [NSMutableDictionary dictionary];
-
-    _messageHandlers[message] = [handler copy];
-}
-
-- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
-{
-    dispatch_block_t handler = _messageHandlers[message.body];
-    if (handler)
-        handler();
-}
-
-@end
-
-@interface TestWKWebViewHostWindow : NSWindow
-@end
-
-@implementation TestWKWebViewHostWindow {
-    BOOL _forceKeyWindow;
-}
-
-static int gEventNumber = 1;
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
-NSEventMask __simulated_forceClickAssociatedEventsMask(id self, SEL _cmd)
-{
-    return NSEventMaskPressure | NSEventMaskLeftMouseDown | NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged;
-}
-#endif
-
-- (void)_mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
-{
-    NSEventType mouseEventType = NSEventTypeLeftMouseDown;
-
-    NSEventMask modifierFlags = 0;
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
-    if (simulatePressure)
-        modifierFlags |= NSEventMaskPressure;
-#else
-    simulatePressure = NO;
-#endif
-
-    NSEvent *event = [NSEvent mouseEventWithType:mouseEventType location:point modifierFlags:modifierFlags timestamp:GetCurrentEventTime() windowNumber:self.windowNumber context:[NSGraphicsContext currentContext] eventNumber:++gEventNumber clickCount:1 pressure:simulatePressure];
-    if (!simulatePressure) {
-        [self sendEvent:event];
-        return;
-    }
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101003
-    IMP simulatedAssociatedEventsMaskImpl = (IMP)__simulated_forceClickAssociatedEventsMask;
-    Method associatedEventsMaskMethod = class_getInstanceMethod([NSEvent class], @selector(associatedEventsMask));
-    IMP originalAssociatedEventsMaskImpl = method_setImplementation(associatedEventsMaskMethod, simulatedAssociatedEventsMaskImpl);
-    @try {
-        [self sendEvent:event];
-    } @finally {
-        // In the case where event sending raises an exception, we still want to restore the original implementation
-        // to prevent subsequent event sending tests from being affected.
-        method_setImplementation(associatedEventsMaskMethod, originalAssociatedEventsMaskImpl);
-    }
-#endif
-}
-
-- (BOOL)isKeyWindow
-{
-    return _forceKeyWindow || [super isKeyWindow];
-}
-
-- (void)makeKeyWindow
-{
-    if (_forceKeyWindow)
-        return;
-
-    _forceKeyWindow = YES;
-    [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidBecomeKeyNotification object:self];
-}
-
-- (void)resignKeyWindow
-{
-    _forceKeyWindow = NO;
-    [super resignKeyWindow];
-}
-
-@end
-
-@implementation TestWKWebView {
-    TestWKWebViewHostWindow *_hostWindow;
-    RetainPtr<TestMessageHandler> _testHandler;
-}
-
-- (instancetype)initWithFrame:(CGRect)frame
-{
-    WKWebViewConfiguration *defaultConfiguration = [[WKWebViewConfiguration alloc] init];
-    return [self initWithFrame:frame configuration:defaultConfiguration];
-}
-
-- (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration
-{
-    if (self = [super initWithFrame:frame configuration:configuration])
-        [self _setUpTestWindow:frame];
-
-    return self;
-}
-
-- (void)_setUpTestWindow:(NSRect)frame
-{
-    _hostWindow = [[TestWKWebViewHostWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
-    [_hostWindow setFrameOrigin:NSMakePoint(0, 0)];
-    [[_hostWindow contentView] addSubview:self];
-    [_hostWindow setIsVisible:YES];
-    [_hostWindow makeKeyAndOrderFront:self];
-}
-
-- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
-{
-    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
-}
-
-- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action
-{
-    if (!_testHandler) {
-        _testHandler = adoptNS([[TestMessageHandler alloc] init]);
-        [[[self configuration] userContentController] addScriptMessageHandler:_testHandler.get() name:@"testHandler"];
-    }
-
-    [_testHandler addMessage:message withHandler:action];
-}
-
-- (void)loadTestPageNamed:(NSString *)pageName
-{
-    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:pageName withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
-    [self loadRequest:request];
-}
-
-- (void)synchronouslyLoadTestPageNamed:(NSString *)pageName
-{
-    [self loadTestPageNamed:pageName];
-    [self _test_waitForDidFinishNavigation];
-}
-
-- (void)typeCharacter:(char)character {
-    NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
-    NSEventType keyDownEventType = NSEventTypeKeyDown;
-    NSEventType keyUpEventType = NSEventTypeKeyUp;
-    [self keyDown:[NSEvent keyEventWithType:keyDownEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
-    [self keyUp:[NSEvent keyEventWithType:keyUpEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
-}
-
-- (NSString *)stringByEvaluatingJavaScript:(NSString *)script
-{
-    __block bool isWaitingForJavaScript = false;
-    __block NSString *evalResult = nil;
-    [self evaluateJavaScript:script completionHandler:^(id result, NSError *error)
-    {
-        evalResult = [NSString stringWithFormat:@"%@", result];
-        isWaitingForJavaScript = true;
-        EXPECT_TRUE(!error);
-    }];
-
-    TestWebKitAPI::Util::run(&isWaitingForJavaScript);
-    return evalResult;
-}
-
-- (void)waitForMessage:(NSString *)message
-{
-    __block bool isDoneWaiting = false;
-    [self performAfterReceivingMessage:message action:^()
-    {
-        isDoneWaiting = true;
-    }];
-    TestWebKitAPI::Util::run(&isDoneWaiting);
-}
-
-- (void)performAfterLoading:(dispatch_block_t)actions {
-    TestMessageHandler *handler = [[TestMessageHandler alloc] init];
-    [handler addMessage:@"loaded" withHandler:actions];
-
-    NSString *_onloadScript_ = @"window._onload_ = () => window.webkit.messageHandlers.onloadHandler.postMessage('loaded')";
-    WKUserScript *script = [[WKUserScript alloc] initWithSource:onloadScript injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:NO];
-
-    WKUserContentController* contentController = [[self configuration] userContentController];
-    [contentController addUserScript:script];
-    [contentController addScriptMessageHandler:handler name:@"onloadHandler"];
-}
-
-@end
-
-#endif /* WK_API_ENABLED && PLATFORM(MAC) */
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to