Changeset 248148 in webkit


Ignore:
Timestamp:
Aug 1, 2019 10:46:32 PM (5 years ago)
Author:
Chris Dumez
Message:

Pages using MessagePorts should be PageCacheable
https://bugs.webkit.org/show_bug.cgi?id=200366
<rdar://problem/53837882>

Reviewed by Geoffrey Garen.

Source/WebCore:

Allow a page to enter PageCache, even if it has MessagePorts (potentially with
pending messages). If there are pending messages on the MessagePorts when
entering PageCache, those will get dispatched upon restoring from PageCache.

Test: fast/history/page-cache-MessagePort-pending-message.html

  • dom/MessagePort.cpp:

(WebCore::MessagePort::messageAvailable):
(WebCore::MessagePort::dispatchMessages):
Do not dispatch messages while in PageCache.

(WebCore::MessagePort::canSuspendForDocumentSuspension const):
Allow pages with MessagePort objects to enter PageCache.

  • dom/ScriptExecutionContext.cpp:

(WebCore::ScriptExecutionContext::resumeActiveDOMObjects):
Make sure pending messages on MessagePorts get dispatched asynchronously after restoring
from PageCache.

  • loader/DocumentLoader.cpp:

(WebCore::areAllLoadersPageCacheAcceptable):
Make sure only CachedResources that are still loading upon load cancelation prevent
entering PageCache.

LayoutTests:

Add layout test coverage.

  • fast/history/page-cache-MessagePort-pending-message-expected.txt: Added.
  • fast/history/page-cache-MessagePort-pending-message.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r248145 r248148  
     12019-08-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Pages using MessagePorts should be PageCacheable
     4        https://bugs.webkit.org/show_bug.cgi?id=200366
     5        <rdar://problem/53837882>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Add layout test coverage.
     10
     11        * fast/history/page-cache-MessagePort-pending-message-expected.txt: Added.
     12        * fast/history/page-cache-MessagePort-pending-message.html: Added.
     13
    1142019-08-01  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r248147 r248148  
     12019-08-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Pages using MessagePorts should be PageCacheable
     4        https://bugs.webkit.org/show_bug.cgi?id=200366
     5        <rdar://problem/53837882>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Allow a page to enter PageCache, even if it has MessagePorts (potentially with
     10        pending messages). If there are pending messages on the MessagePorts when
     11        entering PageCache, those will get dispatched upon restoring from PageCache.
     12
     13        Test: fast/history/page-cache-MessagePort-pending-message.html
     14
     15        * dom/MessagePort.cpp:
     16        (WebCore::MessagePort::messageAvailable):
     17        (WebCore::MessagePort::dispatchMessages):
     18        Do not dispatch messages while in PageCache.
     19
     20        (WebCore::MessagePort::canSuspendForDocumentSuspension const):
     21        Allow pages with MessagePort objects to enter PageCache.
     22
     23        * dom/ScriptExecutionContext.cpp:
     24        (WebCore::ScriptExecutionContext::resumeActiveDOMObjects):
     25        Make sure pending messages on MessagePorts get dispatched asynchronously after restoring
     26        from PageCache.
     27
     28        * loader/DocumentLoader.cpp:
     29        (WebCore::areAllLoadersPageCacheAcceptable):
     30        Make sure only CachedResources that are still loading upon load cancelation prevent
     31        entering PageCache.
     32
    1332019-08-01  Konstantin Tokarev  <annulen@yandex.ru>
    234
  • trunk/Source/WebCore/dom/MessagePort.cpp

    r246490 r248148  
    196196    // This MessagePort object might be disentangled because the port is being transferred,
    197197    // in which case we'll notify it that messages are available once a new end point is created.
    198     if (!m_scriptExecutionContext)
     198    if (!m_scriptExecutionContext || m_scriptExecutionContext->activeDOMObjectsAreSuspended())
    199199        return;
    200200
     
    244244    ASSERT(started());
    245245
    246     if (!isEntangled())
     246    if (!m_scriptExecutionContext || m_scriptExecutionContext->activeDOMObjectsAreSuspended() || !isEntangled())
    247247        return;
    248248
     
    431431bool MessagePort::canSuspendForDocumentSuspension() const
    432432{
    433     return !hasPendingActivity() || (!m_started || m_closed);
     433    return true;
    434434}
    435435
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r243887 r248148  
    308308        return ShouldContinue::Yes;
    309309    });
     310
     311    // In case there were pending messages at the time the script execution context entered PageCache,
     312    // make sure those get dispatched shortly after restoring from PageCache.
     313    processMessageWithMessagePortsSoon();
    310314}
    311315
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r247555 r248148  
    136136            return false;
    137137
    138         // Only image and XHR loads do prevent the page from entering the PageCache.
     138        // Only image and XHR loads do not prevent the page from entering the PageCache.
    139139        // All non-image loads will prevent the page from entering the PageCache.
    140         if (!cachedResource->isImage() && !cachedResource->areAllClientsXMLHttpRequests())
     140        if (cachedResource->isLoading() && !cachedResource->isImage() && !cachedResource->areAllClientsXMLHttpRequests())
    141141            return false;
    142142    }
Note: See TracChangeset for help on using the changeset viewer.