Changeset 180871 in webkit


Ignore:
Timestamp:
Mar 1, 2015 4:08:03 PM (9 years ago)
Author:
Chris Dumez
Message:

Make NotificationCenter / Notification suspendable
https://bugs.webkit.org/show_bug.cgi?id=142117
<rdar://problem/19923085>

Reviewed by Andreas Kling.

Source/WebCore:

Make NotificationCenter / Notification suspendable so that pages using
them can enter the PageCache.

NotificationCenter can safely be suspended if there are no pending
permission requests. This required adding an
"hasPendingPermissionRequests()" callback to the NotificationClient.

Notification can safely be suspended if it is either idle (not showing
yet) or closed.

Tests: fast/history/page-cache-notification-non-suspendable.html

fast/history/page-cache-notification-suspendable.html

  • Modules/notifications/Notification.cpp:

(WebCore::Notification::canSuspend):

  • Modules/notifications/NotificationCenter.cpp:

(WebCore::NotificationCenter::canSuspend):

  • Modules/notifications/NotificationClient.h:

Source/WebKit/mac:

Provide implementation for NotificationClient::hasPendingPermissionRequests().
The implementation is very simplistic. it will only return false if no
request for permission for ever made. This is because there is currently no
easy way to figure out if a permission request is pending or not.

  • WebCoreSupport/WebNotificationClient.h:
  • WebCoreSupport/WebNotificationClient.mm:

(WebNotificationClient::requestPermission):
(WebNotificationClient::hasPendingPermissionRequests):

Source/WebKit/win:

Provide implementation for NotificationClient::hasPendingPermissionRequests().

  • WebCoreSupport/WebDesktopNotificationsDelegate.cpp:

(WebDesktopNotificationsDelegate::requestPermission):
(hasPendingPermissionRequests):

  • WebCoreSupport/WebDesktopNotificationsDelegate.h:

Source/WebKit2:

Provide implementation for NotificationClient::hasPendingPermissionRequests().

  • WebProcess/Notifications/NotificationPermissionRequestManager.cpp:

(WebKit::NotificationPermissionRequestManager::hasPendingPermissionRequests):

  • WebProcess/Notifications/NotificationPermissionRequestManager.h:
  • WebProcess/WebCoreSupport/WebNotificationClient.cpp:

(WebKit::WebNotificationClient::hasPendingPermissionRequests):

  • WebProcess/WebCoreSupport/WebNotificationClient.h:

LayoutTests:

Add layout tests to cover cases where notifications should prevent
entering the PageCache or not.

  • fast/history/page-cache-notification-non-suspendable-expected.txt: Added.
  • fast/history/page-cache-notification-non-suspendable.html: Added.
  • fast/history/page-cache-notification-suspendable-expected.txt: Added.
  • fast/history/page-cache-notification-suspendable.html: Added.
  • platform/efl/TestExpectations:
  • platform/gtk/TestExpectations:
  • platform/ios-simulator/TestExpectations:
  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:
Location:
trunk
Files:
4 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r180870 r180871  
     12015-03-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Make NotificationCenter / Notification suspendable
     4        https://bugs.webkit.org/show_bug.cgi?id=142117
     5        <rdar://problem/19923085>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Add layout tests to cover cases where notifications should prevent
     10        entering the PageCache or not.
     11
     12        * fast/history/page-cache-notification-non-suspendable-expected.txt: Added.
     13        * fast/history/page-cache-notification-non-suspendable.html: Added.
     14        * fast/history/page-cache-notification-suspendable-expected.txt: Added.
     15        * fast/history/page-cache-notification-suspendable.html: Added.
     16        * platform/efl/TestExpectations:
     17        * platform/gtk/TestExpectations:
     18        * platform/ios-simulator/TestExpectations:
     19        * platform/win/TestExpectations:
     20        * platform/wincairo/TestExpectations:
     21
    1222015-03-01  Ryosuke Niwa  <rniwa@webkit.org>
    223
  • trunk/LayoutTests/platform/efl/TestExpectations

    r180836 r180871  
    10751075webkit.org/b/73544 fast/notifications [ Skip ]
    10761076webkit.org/b/73544 http/tests/notifications [ Skip ]
     1077webkit.org/b/73544 fast/history/page-cache-notification-non-suspendable.html [ Skip ]
     1078webkit.org/b/73544 fast/history/page-cache-notification-suspendable.html [ Skip ]
    10771079
    10781080# The test is too slow on Debug bot and randomly fails
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r180776 r180871  
    149149# https://bugs.webkit.org/show_bug.cgi?id=81697 Skip file:// based notifications tests
    150150fast/notifications
     151fast/history/page-cache-notification-non-suspendable.html
     152fast/history/page-cache-notification-suspendable.html
    151153
    152154# we do not enable legacy notifications
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r180811 r180871  
    2727printing
    2828
     29# Web Notifications are not supported on iOS.
     30fast/notifications
     31http/tests/notifications
     32fast/history/page-cache-notification-non-suspendable.html
     33fast/history/page-cache-notification-suspendable.html
     34
    2935# Not supported on iOS
    3036batterystatus
    3137fast/mediastream
    32 fast/notifications
    3338fast/speechsynthesis
    3439gamepad
     
    3944vibration
    4045webaudio
    41 http/tests/notifications
    4246
    4347# ENABLE(MEDIA_CAPTURE) is not enabled
  • trunk/LayoutTests/platform/win/TestExpectations

    r180863 r180871  
    129129fast/notifications/ [ Skip ]
    130130http/tests/notifications/ [ Skip ]
     131fast/history/page-cache-notification-non-suspendable.html [ Skip ]
     132fast/history/page-cache-notification-suspendable.html [ Skip ]
    131133
    132134# TODO DumpRenderTree code to enable Java is currently a no-op. Windows doesn't come with Java by default.
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r180791 r180871  
    13341334fast/notifications
    13351335http/tests/notifications
     1336fast/history/page-cache-notification-non-suspendable.html
     1337fast/history/page-cache-notification-suspendable.html
    13361338
    13371339# These media tests regressed on the bots.  Skipping to make the bots green again.
  • trunk/Source/WebCore/ChangeLog

    r180867 r180871  
     12015-03-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Make NotificationCenter / Notification suspendable
     4        https://bugs.webkit.org/show_bug.cgi?id=142117
     5        <rdar://problem/19923085>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Make NotificationCenter / Notification suspendable so that pages using
     10        them can enter the PageCache.
     11
     12        NotificationCenter can safely be suspended if there are no pending
     13        permission requests. This required adding an
     14        "hasPendingPermissionRequests()" callback to the NotificationClient.
     15
     16        Notification can safely be suspended if it is either idle (not showing
     17        yet) or closed.
     18
     19        Tests: fast/history/page-cache-notification-non-suspendable.html
     20               fast/history/page-cache-notification-suspendable.html
     21
     22        * Modules/notifications/Notification.cpp:
     23        (WebCore::Notification::canSuspend):
     24        * Modules/notifications/NotificationCenter.cpp:
     25        (WebCore::NotificationCenter::canSuspend):
     26        * Modules/notifications/NotificationClient.h:
     27
    1282015-03-01  Ryosuke Niwa  <rniwa@webkit.org>
    229
  • trunk/Source/WebCore/Modules/notifications/Notification.cpp

    r180801 r180871  
    178178bool Notification::canSuspend() const
    179179{
    180     // FIXME: We should try and do better here.
    181     return false;
     180    // We can suspend if the Notification is not shown yet or after it is closed.
     181    return m_state == Idle || m_state == Closed;
    182182}
    183183
  • trunk/Source/WebCore/Modules/notifications/NotificationCenter.cpp

    r180801 r180871  
    113113bool NotificationCenter::canSuspend() const
    114114{
    115     // FIXME: We should try and do better here.
    116     return false;
     115    // We don't need to worry about Notifications because those are ActiveDOMObject too.
     116    // The NotificationCenter can safely be suspended if there are no pending permission
     117    // requests.
     118    return m_callbacks.isEmpty() && (!m_client || !m_client->hasPendingPermissionRequests(scriptExecutionContext()));
    117119}
    118120
  • trunk/Source/WebCore/Modules/notifications/NotificationClient.h

    r172849 r180871  
    8282#endif
    8383
     84    virtual bool hasPendingPermissionRequests(ScriptExecutionContext*) const = 0;
     85
    8486    // Cancel all outstanding requests for the ScriptExecutionContext
    8587    virtual void cancelRequestsForPermission(ScriptExecutionContext*) = 0;
  • trunk/Source/WebKit/mac/ChangeLog

    r180848 r180871  
     12015-03-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Make NotificationCenter / Notification suspendable
     4        https://bugs.webkit.org/show_bug.cgi?id=142117
     5        <rdar://problem/19923085>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Provide implementation for NotificationClient::hasPendingPermissionRequests().
     10        The implementation is very simplistic. it will only return false if no
     11        request for permission for ever made. This is because there is currently no
     12        easy way to figure out if a permission request is pending or not.
     13
     14        * WebCoreSupport/WebNotificationClient.h:
     15        * WebCoreSupport/WebNotificationClient.mm:
     16        (WebNotificationClient::requestPermission):
     17        (WebNotificationClient::hasPendingPermissionRequests):
     18
    1192015-02-28  Simon Fraser  <simon.fraser@apple.com>
    220
  • trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h

    r162139 r180871  
    6767#endif
    6868    virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) override { }
     69    virtual bool hasPendingPermissionRequests(WebCore::ScriptExecutionContext*) const override;
    6970    virtual WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
    7071
     
    7980    typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<RetainPtr<WebNotification>>> NotificationContextMap;
    8081    NotificationContextMap m_notificationContextMap;
     82
     83    bool m_everRequestedPermission { false };
    8184#endif
    8285};
  • trunk/Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm

    r161185 r180871  
    171171    if (![[m_webView UIDelegate] respondsToSelector:selector])
    172172        return;
    173    
     173
     174    m_everRequestedPermission = true;
     175
    174176    WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:context->securityOrigin()];
    175177   
     
    190192}
    191193#endif
     194
     195bool WebNotificationClient::hasPendingPermissionRequests(ScriptExecutionContext*) const
     196{
     197#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     198    // We know permission was requested but we don't know if the client responded. In this case, we play it
     199    // safe and presume there is one pending so that ActiveDOMObjects don't get suspended.
     200    return m_everRequestedPermission;
     201#else
     202    return false;
     203#endif
     204}
    192205
    193206#if ENABLE(NOTIFICATIONS)
  • trunk/Source/WebKit/win/ChangeLog

    r180765 r180871  
     12015-03-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Make NotificationCenter / Notification suspendable
     4        https://bugs.webkit.org/show_bug.cgi?id=142117
     5        <rdar://problem/19923085>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Provide implementation for NotificationClient::hasPendingPermissionRequests().
     10
     11        * WebCoreSupport/WebDesktopNotificationsDelegate.cpp:
     12        (WebDesktopNotificationsDelegate::requestPermission):
     13        (hasPendingPermissionRequests):
     14        * WebCoreSupport/WebDesktopNotificationsDelegate.h:
     15
    1162015-02-26  Brent Fulgham  <bfulgham@apple.com>
    217
  • trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp

    r176892 r180871  
    169169}
    170170
    171 void WebDesktopNotificationsDelegate::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback)
     171void WebDesktopNotificationsDelegate::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback>)
    172172{
    173173    BString org(origin->toString());
     
    182182void WebDesktopNotificationsDelegate::cancelRequestsForPermission(ScriptExecutionContext* context)
    183183{
     184}
     185
     186bool hasPendingPermissionRequests(ScriptExecutionContext*) const
     187{
     188    // We can safely return false here because our implementation for requestPermission() never calls
     189    // the completion callback.
     190    return false;
    184191}
    185192
  • trunk/Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h

    r156550 r180871  
    5757    virtual void requestPermission(WebCore::SecurityOrigin*, PassRefPtr<WebCore::NotificationPermissionCallback>);
    5858#endif
     59    virtual bool hasPendingPermissionRequests(WebCore::ScriptExecutionContext*) const override;
    5960    virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*);
    6061    virtual WebCore::NotificationClient::Permission checkPermission(const URL&);
  • trunk/Source/WebKit2/ChangeLog

    r180869 r180871  
     12015-03-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Make NotificationCenter / Notification suspendable
     4        https://bugs.webkit.org/show_bug.cgi?id=142117
     5        <rdar://problem/19923085>
     6
     7        Reviewed by Andreas Kling.
     8
     9        Provide implementation for NotificationClient::hasPendingPermissionRequests().
     10
     11        * WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
     12        (WebKit::NotificationPermissionRequestManager::hasPendingPermissionRequests):
     13        * WebProcess/Notifications/NotificationPermissionRequestManager.h:
     14        * WebProcess/WebCoreSupport/WebNotificationClient.cpp:
     15        (WebKit::WebNotificationClient::hasPendingPermissionRequests):
     16        * WebProcess/WebCoreSupport/WebNotificationClient.h:
     17
    1182015-03-01  Antti Koivisto  <antti@apple.com>
    219
  • trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp

    r179409 r180871  
    121121}
    122122
     123bool NotificationPermissionRequestManager::hasPendingPermissionRequests(SecurityOrigin* origin) const
     124{
     125#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
     126    return m_originToIDMap.contains(origin);
     127#else
     128    UNUSED_PARAM(origin);
     129    return false;
     130#endif
     131}
     132
    123133NotificationClient::Permission NotificationPermissionRequestManager::permissionLevel(SecurityOrigin* securityOrigin)
    124134{
  • trunk/Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h

    r149848 r180871  
    5757#endif
    5858    void cancelRequest(WebCore::SecurityOrigin*);
     59    bool hasPendingPermissionRequests(WebCore::SecurityOrigin*) const;
    5960   
    6061    WebCore::NotificationClient::Permission permissionLevel(WebCore::SecurityOrigin*);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp

    r179409 r180871  
    8787#endif
    8888
     89bool WebNotificationClient::hasPendingPermissionRequests(ScriptExecutionContext* context) const
     90{
     91    return m_page->notificationPermissionRequestManager()->hasPendingPermissionRequests(context->securityOrigin());
     92}
     93
    8994void WebNotificationClient::cancelRequestsForPermission(ScriptExecutionContext* context)
    9095{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h

    r162139 r180871  
    5959#endif
    6060    virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*) override;
     61    virtual bool hasPendingPermissionRequests(WebCore::ScriptExecutionContext*) const override;
    6162    virtual NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*) override;
    6263   
Note: See TracChangeset for help on using the changeset viewer.