Pages using MessagePorts should be PageCacheable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2019 05:46:32 +0000 (05:46 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2019 05:46:32 +0000 (05:46 +0000)
commitad4749b66a2ecea83d98f59b5ff9a7a2cad2bf96
tree78589261bebcc53941a00d1c1079b8ddaea1376c
parent6df67291896c9c3dfdf2405b28f32b66c6835c90
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248148 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/history/page-cache-MessagePort-pending-message-expected.txt [new file with mode: 0644]
LayoutTests/fast/history/page-cache-MessagePort-pending-message.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/MessagePort.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/loader/DocumentLoader.cpp