⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 211045 in webkit


Ignore:
Timestamp:
Jan 23, 2017, 11:23:34 AM (10 years ago)
Author:
jer.noble@apple.com
Message:

Source/WebCore:
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):

Source/WebKit2:
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.

Tools:
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:]):

Location:
trunk
Files:
22 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r211042 r211045  
     12017-01-23  Jer Noble  <jer.noble@apple.com>
     2
     3        REGRESSION (r208149): Video details does not apear and missing scrubber in Control Center
     4        https://bugs.webkit.org/show_bug.cgi?id=167233
     5
     6        Reviewed by Alex Christensen.
     7
     8        Test: In TestWebKitAPI, NowPlayingControlsTests.NowPlayingControlsIOS
     9
     10        In r208149, we introduced a new media type, Video, and renamed the old type to
     11        VideoAudio (to be able to distinguish between video-with-audio and silent-video).
     12        But we missed one place where that type needs to be renamed.
     13
     14        For testing purposes, overload methods from PlatformMediaSessionManager which WebKit2 uses
     15        to report the current now playing session and it's information.
     16
     17        * platform/audio/ios/MediaSessionManagerIOS.h:
     18        * platform/audio/ios/MediaSessionManagerIOS.mm:
     19        (WebCore::MediaSessionManageriOS::nowPlayingEligibleSession):
     20        (WebCore::MediaSessionManageriOS::updateNowPlayingInfo):
     21
    1222017-01-23  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h

    r200466 r211045  
    7171    bool sessionCanLoadMedia(const PlatformMediaSession&) const override;
    7272
     73    bool hasActiveNowPlayingSession() const final { return m_nowPlayingActive; }
     74    String lastUpdatedNowPlayingTitle() const final { return m_reportedTitle; }
     75    double lastUpdatedNowPlayingDuration() const final { return m_reportedDuration; }
     76    double lastUpdatedNowPlayingElapsedTime() const final { return m_reportedCurrentTime; }
     77
    7378    PlatformMediaSession* nowPlayingEligibleSession();
    7479   
     
    7681    double m_reportedRate { 0 };
    7782    double m_reportedDuration { 0 };
     83    double m_reportedCurrentTime { 0 };
    7884    String m_reportedTitle;
    7985    bool m_nowPlayingActive { false };
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r210104 r211045  
    220220    return findSession([] (PlatformMediaSession& session, size_t) {
    221221        PlatformMediaSession::MediaType type = session.mediaType();
    222         if (type != PlatformMediaSession::Video && type != PlatformMediaSession::Audio)
     222        if (type != PlatformMediaSession::VideoAudio && type != PlatformMediaSession::Audio)
    223223            return false;
    224224
     
    250250    double duration = currentSession->duration();
    251251    double rate = currentSession->state() == PlatformMediaSession::Playing ? 1 : 0;
     252    double currentTime = currentSession->currentTime();
    252253    if (m_reportedTitle == title && m_reportedRate == rate && m_reportedDuration == duration) {
    253254        LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo - nothing new to show");
     
    258259    m_reportedDuration = duration;
    259260    m_reportedTitle = title;
     261    m_reportedCurrentTime = currentTime;
    260262
    261263    auto info = adoptNS([[NSMutableDictionary alloc] init]);
     
    266268    info.get()[MPNowPlayingInfoPropertyPlaybackRate] = @(rate);
    267269
    268     double currentTime = currentSession->currentTime();
    269270    if (std::isfinite(currentTime) && currentTime != MediaPlayer::invalidTime())
    270271        info.get()[MPNowPlayingInfoPropertyElapsedPlaybackTime] = @(currentTime);
  • trunk/Source/WebKit2/ChangeLog

    r211042 r211045  
     12017-01-23  Jer Noble  <jer.noble@apple.com>
     2
     3        Video details does not apear and missing scrubber in Control Center
     4        https://bugs.webkit.org/show_bug.cgi?id=167233
     5
     6        Reviewed by Alex Christensen.
     7
     8        Make requestActiveNowPlayingSessionInfo() and handleActiveNowPlayingSessionInfoResponse()
     9        work in PLATFORM(IOS).
     10
     11        * UIProcess/API/Cocoa/WKWebView.mm:
     12        (-[WKWebView _requestActiveNowPlayingSessionInfo]):
     13        (-[WKWebView _handleActiveNowPlayingSessionInfoResponse:title:duration:elapsedTime:]):
     14        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     15        * UIProcess/PageClient.h:
     16        * UIProcess/WebPageProxy.cpp:
     17        (WebKit::WebPageProxy::requestActiveNowPlayingSessionInfo):
     18        (WebKit::WebPageProxy::handleActiveNowPlayingSessionInfoResponse):
     19        * UIProcess/WebPageProxy.h:
     20        * UIProcess/WebPageProxy.messages.in:
     21        * UIProcess/ios/PageClientImplIOS.h:
     22        * UIProcess/ios/PageClientImplIOS.mm:
     23        (WebKit::PageClientImpl::handleActiveNowPlayingSessionInfoResponse):
     24        * WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
     25        (WebKit::WebPage::requestActiveNowPlayingSessionInfo):
     26        * WebProcess/WebPage/WebPage.h:
     27        * WebProcess/WebPage/WebPage.messages.in:
     28        * WebProcess/WebPage/mac/WebPageMac.mm:
     29        (WebKit::WebPage::requestActiveNowPlayingSessionInfo): Deleted.
     30
    1312017-01-23  Chris Dumez  <cdumez@apple.com>
    232
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r210913 r211045  
    48624862}
    48634863
     4864- (void)_insertText:(id)string replacementRange:(NSRange)replacementRange
     4865{
     4866    [self insertText:string replacementRange:replacementRange];
     4867}
     4868
     4869- (void)_setHeaderBannerHeight:(int)height
     4870{
     4871    _page->setHeaderBannerHeightForTesting(height);
     4872}
     4873
     4874- (void)_setFooterBannerHeight:(int)height
     4875{
     4876    _page->setFooterBannerHeightForTesting(height);
     4877}
     4878
     4879#endif // PLATFORM(MAC)
     4880
    48644881- (void)_requestActiveNowPlayingSessionInfo
    48654882{
     
    48724889    // Overridden by subclasses.
    48734890}
    4874 
    4875 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange
    4876 {
    4877     [self insertText:string replacementRange:replacementRange];
    4878 }
    4879 
    4880 - (void)_setHeaderBannerHeight:(int)height
    4881 {
    4882     _page->setHeaderBannerHeightForTesting(height);
    4883 }
    4884 
    4885 - (void)_setFooterBannerHeight:(int)height
    4886 {
    4887     _page->setFooterBannerHeightForTesting(height);
    4888 }
    4889 
    4890 #endif // PLATFORM(MAC)
    48914891
    48924892- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r209975 r211045  
    309309- (void)_didUpdateCandidateListVisibility:(BOOL)visible WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    310310@property (nonatomic, readonly) BOOL _shouldRequestCandidates WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    311 - (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    312 - (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    313 
    314311- (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(WK_MAC_TBA));
    315312
     
    318315#endif
    319316
     317- (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     318- (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     319
    320320- (void)_setPageScale:(CGFloat)scale withOrigin:(CGPoint)origin WK_API_AVAILABLE(ios(WK_IOS_TBA));
    321321- (CGFloat)_pageScale WK_API_AVAILABLE(ios(WK_IOS_TBA));
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r210689 r211045  
    254254    virtual void removeNavigationGestureSnapshot() = 0;
    255255    virtual void handleControlledElementIDResponse(const String&) = 0;
    256     virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) = 0;
    257256
    258257    virtual CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const = 0;
     
    284283    virtual void setEditableElementIsFocused(bool) = 0;
    285284#endif // PLATFORM(MAC)
     285
     286#if PLATFORM(COCOA)
     287    virtual void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) = 0;
     288#endif
    286289
    287290#if PLATFORM(IOS)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r211007 r211045  
    64786478}
    64796479
    6480 void WebPageProxy::requestActiveNowPlayingSessionInfo()
    6481 {
    6482     m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), m_pageID);
    6483 }
    6484 
    6485 void WebPageProxy::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const
    6486 {
    6487     m_pageClient.handleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime);
    6488 }
    6489 
    64906480void WebPageProxy::handleControlledElementIDResponse(const String& identifier) const
    64916481{
     
    65006490    return false;
    65016491#endif
     6492}
     6493#endif
     6494
     6495#if PLATFORM(COCOA)
     6496void WebPageProxy::requestActiveNowPlayingSessionInfo()
     6497{
     6498    m_process->send(Messages::WebPage::RequestActiveNowPlayingSessionInfo(), m_pageID);
     6499}
     6500
     6501void WebPageProxy::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const
     6502{
     6503    m_pageClient.handleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime);
    65026504}
    65036505#endif
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r211007 r211045  
    10651065    void requestControlledElementID() const;
    10661066    void handleControlledElementIDResponse(const String&) const;
     1067    bool isPlayingVideoInEnhancedFullscreen() const;
     1068#endif
     1069
     1070#if PLATFORM(COCOA)
    10671071    void requestActiveNowPlayingSessionInfo();
    10681072    void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) const;
    1069     bool isPlayingVideoInEnhancedFullscreen() const;
    10701073#endif
    10711074
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in

    r210753 r211045  
    484484#if PLATFORM(MAC)
    485485    DidHandleAcceptedCandidate()
     486#endif
     487
     488#if PLATFORM(COCOA)
    486489    HandleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, String title, double duration, double elapsedTime)
    487490#endif
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r210689 r211045  
    195195    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
    196196
     197    void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
     198
    197199    WKContentView *m_contentView;
    198200    WKWebView *m_webView;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r210689 r211045  
    3535#import "NativeWebKeyboardEvent.h"
    3636#import "NavigationState.h"
     37#import "StringUtilities.h"
    3738#import "UIKitSPI.h"
    3839#import "ViewSnapshotStore.h"
     
    750751}
    751752
     753void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
     754{
     755    [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];
     756}
     757
    752758} // namespace WebKit
    753759
  • trunk/Source/WebKit2/WebProcess/WebPage/Cocoa/WebPageCocoa.mm

    r202889 r211045  
    2828
    2929#import "LoadParameters.h"
     30#import "WebPageProxyMessages.h"
     31#import <WebCore/PlatformMediaSessionManager.h>
    3032
    3133#if PLATFORM(COCOA)
     
    4042}
    4143
     44void WebPage::requestActiveNowPlayingSessionInfo()
     45{
     46    bool hasActiveSession = false;
     47    String title = emptyString();
     48    double duration = NAN;
     49    double elapsedTime = NAN;
     50    if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists()) {
     51        hasActiveSession = sharedManager->hasActiveNowPlayingSession();
     52        title = sharedManager->lastUpdatedNowPlayingTitle();
     53        duration = sharedManager->lastUpdatedNowPlayingDuration();
     54        elapsedTime = sharedManager->lastUpdatedNowPlayingElapsedTime();
     55    }
     56
     57    send(Messages::WebPageProxy::HandleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime));
     58}
     59
    4260} // namespace WebKit
    4361
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r211007 r211045  
    12251225
    12261226    void handleAcceptedCandidate(WebCore::TextCheckingResult);
     1227#endif
     1228
     1229#if PLATFORM(COCOA)
    12271230    void requestActiveNowPlayingSessionInfo();
    12281231#endif
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r211007 r211045  
    425425
    426426    HandleAcceptedCandidate(struct WebCore::TextCheckingResult acceptedCandidate)
    427     RequestActiveNowPlayingSessionInfo()
    428427
    429428    SetHeaderBannerHeightForTesting(int height);
    430429    SetFooterBannerHeightForTesting(int height);
     430#endif
     431
     432#if PLATFORM(COCOA)
     433    RequestActiveNowPlayingSessionInfo()
    431434#endif
    432435
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm

    r210845 r211045  
    7777#import <WebCore/PageOverlayController.h>
    7878#import <WebCore/PlatformKeyboardEvent.h>
    79 #import <WebCore/PlatformMediaSessionManager.h>
    8079#import <WebCore/PluginDocument.h>
    8180#import <WebCore/RenderElement.h>
     
    161160    frame->editor().handleAcceptedCandidate(acceptedCandidate);
    162161    send(Messages::WebPageProxy::DidHandleAcceptedCandidate());
    163 }
    164 
    165 void WebPage::requestActiveNowPlayingSessionInfo()
    166 {
    167     bool hasActiveSession = false;
    168     String title = emptyString();
    169     double duration = NAN;
    170     double elapsedTime = NAN;
    171     if (auto* sharedManager = WebCore::PlatformMediaSessionManager::sharedManagerIfExists()) {
    172         hasActiveSession = sharedManager->hasActiveNowPlayingSession();
    173         title = sharedManager->lastUpdatedNowPlayingTitle();
    174         duration = sharedManager->lastUpdatedNowPlayingDuration();
    175         elapsedTime = sharedManager->lastUpdatedNowPlayingElapsedTime();
    176     }
    177 
    178     send(Messages::WebPageProxy::HandleActiveNowPlayingSessionInfoResponse(hasActiveSession, title, duration, elapsedTime));
    179162}
    180163
  • trunk/Tools/ChangeLog

    r211015 r211045  
     12017-01-23  Jer Noble  <jer.noble@apple.com>
     2
     3        Video details does not apear and missing scrubber in Control Center
     4        https://bugs.webkit.org/show_bug.cgi?id=167233
     5
     6        Reviewed by Alex Christensen.
     7
     8        Refactor TestWKWebViewMac to work on PLATFORM(IOS). Add a new test to
     9        NowPlayingControlTests for iOS.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm:
     13        (-[NowPlayingTestWebView setWindowVisible:]):
     14        (TestWebKitAPI::TEST):
     15        * TestWebKitAPI/Tests/WebKit2Cocoa/SnapshotStore.mm:
     16        * TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm:
     17        * TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm:
     18        * TestWebKitAPI/cocoa/TestWKWebView.h: Renamed from Tools/TestWebKitAPI/mac/TestWKWebViewMac.h.
     19        * TestWebKitAPI/cocoa/TestWKWebView.mm: Renamed from Tools/TestWebKitAPI/mac/TestWKWebViewMac.mm.
     20        (SOFT_LINK_CLASS):
     21        (-[TestMessageHandler addMessage:withHandler:]):
     22        (-[TestMessageHandler userContentController:didReceiveScriptMessage:]):
     23        (__simulated_forceClickAssociatedEventsMask):
     24        (-[TestWKWebViewHostWindow _mouseDownAtPoint:simulatePressure:]):
     25        (-[TestWKWebViewHostWindow isKeyWindow]):
     26        (-[TestWKWebViewHostWindow makeKeyWindow]):
     27        (-[TestWKWebViewHostWindow resignKeyWindow]):
     28        (-[TestWKWebView initWithFrame:]):
     29        (-[TestWKWebView initWithFrame:configuration:]):
     30        (-[TestWKWebView _setUpTestWindow:]):
     31        (-[TestWKWebView performAfterReceivingMessage:action:]):
     32        (-[TestWKWebView loadTestPageNamed:]):
     33        (-[TestWKWebView synchronouslyLoadTestPageNamed:]):
     34        (-[TestWKWebView stringByEvaluatingJavaScript:]):
     35        (-[TestWKWebView waitForMessage:]):
     36        (-[TestWKWebView performAfterLoading:]):
     37        (-[TestWKWebView mouseDownAtPoint:simulatePressure:]):
     38        (-[TestWKWebView typeCharacter:]):
     39
    1402017-01-21  Carlos Garcia Campos  <cgarcia@igalia.com>
    241
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r210790 r211045  
    8787                2EFF06C71D886A580004BB30 /* change-video-source-on-end.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */; };
    8888                2EFF06CD1D8A429A0004BB30 /* input-field-in-scrollable-document.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */; };
    89                 2EFF06D41D8AEDBB0004BB30 /* TestWKWebViewMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D31D8AEDBB0004BB30 /* TestWKWebViewMac.mm */; };
     89                2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */; };
    9090                2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */; };
    9191                315118101DB1AE4000176304 /* ExtendedColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3151180F1DB1ADD500176304 /* ExtendedColor.cpp */; };
     
    881881                2EFF06C61D886A560004BB30 /* change-video-source-on-end.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "change-video-source-on-end.html"; sourceTree = "<group>"; };
    882882                2EFF06CC1D8A42910004BB30 /* input-field-in-scrollable-document.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "input-field-in-scrollable-document.html"; sourceTree = "<group>"; };
    883                 2EFF06D21D8AEDBB0004BB30 /* TestWKWebViewMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestWKWebViewMac.h; sourceTree = "<group>"; };
    884                 2EFF06D31D8AEDBB0004BB30 /* TestWKWebViewMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestWKWebViewMac.mm; sourceTree = "<group>"; };
     883                2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestWKWebView.h; path = cocoa/TestWKWebView.h; sourceTree = "<group>"; };
     884                2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestWKWebView.mm; path = cocoa/TestWKWebView.mm; sourceTree = "<group>"; };
    885885                2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCandidateTests.mm; sourceTree = "<group>"; };
    886886                3151180F1DB1ADD500176304 /* ExtendedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendedColor.cpp; sourceTree = "<group>"; };
     
    14351435                                A14FC58D1B8AE36500D107EB /* TestProtocol.h */,
    14361436                                A14FC58E1B8AE36500D107EB /* TestProtocol.mm */,
     1437                                2EFF06D21D8AEDBB0004BB30 /* TestWKWebView.h */,
     1438                                2EFF06D31D8AEDBB0004BB30 /* TestWKWebView.mm */,
    14371439                                7C83E0391D0A602700FEBCF3 /* UtilitiesCocoa.mm */,
    14381440                                A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */,
     
    20102012                                29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */,
    20112013                                29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */,
    2012                                 2EFF06D21D8AEDBB0004BB30 /* TestWKWebViewMac.h */,
    2013                                 2EFF06D31D8AEDBB0004BB30 /* TestWKWebViewMac.mm */,
    20142014                                C08587BE13FE956C001EF4E5 /* WebKitAgnosticTest.h */,
    20152015                                C08587BD13FE956C001EF4E5 /* WebKitAgnosticTest.mm */,
     
    25682568                                7CCE7EFC1A411AE600447C4C /* InjectedBundleFrameHitTest.cpp in Sources */,
    25692569                                7CCE7EFD1A411AE600447C4C /* InjectedBundleInitializationUserDataCallbackWins.cpp in Sources */,
    2570                                 2EFF06D41D8AEDBB0004BB30 /* TestWKWebViewMac.mm in Sources */,
     2570                                2EFF06D41D8AEDBB0004BB30 /* TestWKWebView.mm in Sources */,
    25712571                                7C83E0B81D0A64BD00FEBCF3 /* InjectedBundleMakeAllShadowRootsOpen.cpp in Sources */,
    25722572                                7CCE7EC31A411A7E00447C4C /* InspectorBar.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/NowPlayingControlsTests.mm

    r207220 r211045  
    2727
    2828#import "PlatformUtilities.h"
    29 #import "TestWKWebViewMac.h"
     29#import "TestWKWebView.h"
    3030
    3131#import <WebKit/WKWebViewConfigurationPrivate.h>
    3232#import <WebKit/WKWebViewPrivate.h>
    3333
    34 #if WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
     34#if WK_API_ENABLED && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201)
    3535
    3636@interface NowPlayingTestWebView : TestWKWebView
     
    9494    _receivedNowPlayingInfoResponse = true;
    9595}
     96
     97- (void)setWindowVisible:(BOOL)isVisible
     98{
     99#if PLATFORM(MAC)
     100    [self.window setIsVisible:isVisible];
     101#else
     102    self.window.hidden = !isVisible;
     103#endif
     104}
    96105@end
    97106
    98107namespace TestWebKitAPI {
    99108
     109#if PLATFORM(MAC)
    100110TEST(NowPlayingControlsTests, NowPlayingControlsDoNotShowForForegroundPage)
    101111{
     
    106116    [webView waitForMessage:@"playing"];
    107117
    108     [webView.window setIsVisible:YES];
     118    [webView setWindowVisible:YES];
    109119    [webView.window makeKeyWindow];
    110120    [webView expectHasActiveNowPlayingSession:NO];
     
    123133    [webView waitForMessage:@"playing"];
    124134
    125     [webView.window setIsVisible:NO];
     135    [webView setWindowVisible:NO];
    126136    [webView.window resignKeyWindow];
    127137    [webView expectHasActiveNowPlayingSession:YES];
     
    140150    [webView waitForMessage:@"playing"];
    141151
    142     [webView.window setIsVisible:NO];
     152    [webView setWindowVisible:NO];
    143153    [webView.window resignKeyWindow];
    144154
    145155    [webView expectHasActiveNowPlayingSession:YES];
    146156
    147     [webView.window setIsVisible:YES];
     157    [webView setWindowVisible:YES];
    148158    [webView.window makeKeyWindow];
    149159
     
    163173    [webView waitForMessage:@"playing"];
    164174
    165     [webView mouseDownAtPoint:NSMakePoint(240, 160) simulatePressure:YES];
    166     [webView.window setIsVisible:NO];
     175    [webView stringByEvaluatingJavaScript:@"document.querySelector('video').muted = true"];
     176    [webView setWindowVisible:NO];
    167177    [webView.window resignKeyWindow];
    168178
     
    173183    ASSERT_TRUE(isnan(webView.lastUpdatedElapsedTime));
    174184}
     185#endif // PLATFORM(MAC)
     186
     187#if PLATFORM(IOS)
     188TEST(NowPlayingControlsTests, NowPlayingControlsIOS)
     189{
     190    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
     191    configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
     192    NowPlayingTestWebView *webView = [[NowPlayingTestWebView alloc] initWithFrame:NSMakeRect(0, 0, 480, 320) configuration:configuration];
     193    [webView loadTestPageNamed:@"large-video-test-now-playing"];
     194    [webView waitForMessage:@"playing"];
     195
     196    [webView expectHasActiveNowPlayingSession:YES];
     197    ASSERT_STREQ("foo", webView.lastUpdatedTitle.UTF8String);
     198    ASSERT_EQ(10, webView.lastUpdatedDuration);
     199    ASSERT_GE(webView.lastUpdatedElapsedTime, 0);
     200}
     201#endif
    175202
    176203} // namespace TestWebKitAPI
    177204
    178 #endif // WK_API_ENABLED && PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201
     205#endif // WK_API_ENABLED && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201)
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/SnapshotStore.mm

    r206833 r211045  
    3232#import "Test.h"
    3333#import "TestNavigationDelegate.h"
    34 #import "TestWKWebViewMac.h"
     34#import "TestWKWebView.h"
    3535#import <WebKit/WKBackForwardListItemPrivate.h>
    3636#import <WebKit/WKPage.h>
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/VideoControlsManager.mm

    r208655 r211045  
    2727
    2828#import "PlatformUtilities.h"
    29 #import "TestWKWebViewMac.h"
     29#import "TestWKWebView.h"
    3030
    3131#import <WebKit/WKWebViewConfigurationPrivate.h>
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewCandidateTests.mm

    r206335 r211045  
    2929
    3030#import "PlatformUtilities.h"
    31 #import "TestWKWebViewMac.h"
     31#import "TestWKWebView.h"
    3232
    3333#import <Carbon/Carbon.h>
  • trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.h

    r211044 r211045  
    2424 */
    2525
    26 #ifndef TestWKWebViewMac_h
    27 #define TestWKWebViewMac_h
    28 
    2926#import <WebKit/WebKit.h>
    3027
    31 #if WK_API_ENABLED && PLATFORM(MAC)
     28#if WK_API_ENABLED
    3229
    3330@interface TestMessageHandler : NSObject <WKScriptMessageHandler>
     
    3633
    3734@interface TestWKWebView : WKWebView
    38 // Simulates clicking with a pressure-sensitive device, if possible.
    39 - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
    4035- (void)performAfterReceivingMessage:(NSString *)message action:(dispatch_block_t)action;
    4136- (void)loadTestPageNamed:(NSString *)pageName;
    4237- (void)synchronouslyLoadTestPageNamed:(NSString *)pageName;
    43 - (void)typeCharacter:(char)character;
    4438- (NSString *)stringByEvaluatingJavaScript:(NSString *)script;
    4539- (void)waitForMessage:(NSString *)message;
     
    4741@end
    4842
    49 #endif /* WK_API_ENABLED && PLATFORM(MAC) */
     43#if PLATFORM(MAC)
     44@interface TestWKWebView (MacOnly)
     45// Simulates clicking with a pressure-sensitive device, if possible.
     46- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure;
     47- (void)typeCharacter:(char)character;
     48@end
     49#endif
    5050
    51 #endif /* TestWKWebViewMac_h */
     51#endif // WK_API_ENABLED
     52
  • trunk/Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

    r211044 r211045  
    2525
    2626#import "config.h"
    27 #import "TestWKWebViewMac.h"
    28 
    29 #if WK_API_ENABLED && PLATFORM(MAC)
     27#import "TestWKWebView.h"
     28
     29#if WK_API_ENABLED
    3030
    3131#import "TestNavigationDelegate.h"
    3232#import "Utilities.h"
    3333
    34 #import <AppKit/AppKit.h>
    35 #import <Carbon/Carbon.h>
    3634#import <WebKit/WebKitPrivate.h>
    3735#import <objc/runtime.h>
    3836#import <wtf/RetainPtr.h>
     37
     38#if PLATFORM(MAC)
     39#import <AppKit/AppKit.h>
     40#import <Carbon/Carbon.h>
    3941#import <wtf/mac/AppKitCompatibilityDeclarations.h>
     42#endif
     43
     44#if PLATFORM(IOS)
     45#import <WebCore/SoftLinking.h>
     46SOFT_LINK_FRAMEWORK(UIKit)
     47SOFT_LINK_CLASS(UIKit, UIWindow)
     48#endif
    4049
    4150@implementation TestMessageHandler {
     
    6069@end
    6170
     71#if PLATFORM(MAC)
    6272@interface TestWKWebViewHostWindow : NSWindow
     73#else
     74@interface TestWKWebViewHostWindow : UIWindow
     75#endif // PLATFORM(MAC)
    6376@end
    6477
     
    6780}
    6881
     82#if PLATFORM(MAC)
    6983static int gEventNumber = 1;
    7084
     
    107121#endif
    108122}
     123#endif // PLATFORM(MAC)
    109124
    110125- (BOOL)isKeyWindow
     
    119134
    120135    _forceKeyWindow = YES;
     136#if PLATFORM(MAC)
    121137    [[NSNotificationCenter defaultCenter] postNotificationName:NSWindowDidBecomeKeyNotification object:self];
     138#else
     139    [[NSNotificationCenter defaultCenter] postNotificationName:UIWindowDidBecomeKeyNotification object:self];
     140#endif
    122141}
    123142
     
    151170- (void)_setUpTestWindow:(NSRect)frame
    152171{
     172#if PLATFORM(MAC)
    153173    _hostWindow = [[TestWKWebViewHostWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO];
    154174    [_hostWindow setFrameOrigin:NSMakePoint(0, 0)];
     175    [_hostWindow setIsVisible:YES];
    155176    [[_hostWindow contentView] addSubview:self];
    156     [_hostWindow setIsVisible:YES];
    157177    [_hostWindow makeKeyAndOrderFront:self];
    158 }
    159 
    160 - (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
    161 {
    162     [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
     178#else
     179    _hostWindow = [[TestWKWebViewHostWindow alloc] initWithFrame:frame];
     180    _hostWindow.hidden = NO;
     181    [_hostWindow addSubview:self];
     182#endif
    163183}
    164184
     
    183203    [self loadTestPageNamed:pageName];
    184204    [self _test_waitForDidFinishNavigation];
    185 }
    186 
    187 - (void)typeCharacter:(char)character {
    188     NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
    189     NSEventType keyDownEventType = NSEventTypeKeyDown;
    190     NSEventType keyUpEventType = NSEventTypeKeyUp;
    191     [self keyDown:[NSEvent keyEventWithType:keyDownEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
    192     [self keyUp:[NSEvent keyEventWithType:keyUpEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
    193205}
    194206
     
    232244@end
    233245
    234 #endif /* WK_API_ENABLED && PLATFORM(MAC) */
     246#if PLATFORM(MAC)
     247@implementation TestWKWebView (MacOnly)
     248- (void)mouseDownAtPoint:(NSPoint)point simulatePressure:(BOOL)simulatePressure
     249{
     250    [_hostWindow _mouseDownAtPoint:point simulatePressure:simulatePressure];
     251}
     252
     253- (void)typeCharacter:(char)character {
     254    NSString *characterAsString = [NSString stringWithFormat:@"%c" , character];
     255    NSEventType keyDownEventType = NSEventTypeKeyDown;
     256    NSEventType keyUpEventType = NSEventTypeKeyUp;
     257    [self keyDown:[NSEvent keyEventWithType:keyDownEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
     258    [self keyUp:[NSEvent keyEventWithType:keyUpEventType location:NSZeroPoint modifierFlags:0 timestamp:GetCurrentEventTime() windowNumber:_hostWindow.windowNumber context:nil characters:characterAsString charactersIgnoringModifiers:characterAsString isARepeat:NO keyCode:character]];
     259}
     260@end
     261#endif
     262
     263#endif // WK_API_ENABLED
Note: See TracChangeset for help on using the changeset viewer.