Pages frequently fails to enter the back/forward cache due to pending loads
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2019 06:17:17 +0000 (06:17 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2019 06:17:17 +0000 (06:17 +0000)
commit7a76692109f8b5a33914334294b72e5d31042ce9
tree3a62e18807ff1a380ddd0a87373f9bd774733e5d
parent3f120524ad8f87eac080c7ed9bda8ce4210ac224
Pages frequently fails to enter the back/forward cache due to pending loads
https://bugs.webkit.org/show_bug.cgi?id=202289
<rdar://problem/55758506>

Reviewed by Geoffrey Garen.

Source/WebCore:

Allow pages to enter the back / forward cache, even if they have pending loads.
Note that these pending loads get cancelled. Also note that we won't enter page
cache unless the 'load' event has been fired in the main frame, since a
HistoryItem would not get created otherwise. This was causing frequent transient
failures to enter the back / forward cache while browsing (e.g. on weather.com).

Test: http/tests/navigation/page-cache-pending-load.html

* history/PageCache.cpp:
(WebCore::canCacheFrame):
* loader/CrossOriginPreflightChecker.cpp:
* loader/CrossOriginPreflightChecker.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::setMainDocumentError):
(WebCore::DocumentLoader::stopLoading):
* loader/DocumentLoader.h:
* loader/DocumentThreadableLoader.cpp:
* loader/DocumentThreadableLoader.h:
* loader/cache/CachedResource.cpp:
* loader/cache/CachedResource.h:
* loader/cache/CachedResourceClient.h:
(WebCore::CachedResourceClient::deprecatedDidReceiveCachedResource):
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::mainFrameHasNotFinishedLoadingKey):
* page/DiagnosticLoggingKeys.h:

LayoutTests:

Add layout test coverage.

* http/tests/navigation/page-cache-pending-load-expected.txt: Added.
* http/tests/navigation/page-cache-pending-load.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/navigation/page-cache-pending-load-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/navigation/page-cache-pending-load.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/history/PageCache.cpp
Source/WebCore/loader/CrossOriginPreflightChecker.cpp
Source/WebCore/loader/CrossOriginPreflightChecker.h
Source/WebCore/loader/DocumentLoader.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/DocumentThreadableLoader.h
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h
Source/WebCore/loader/cache/CachedResourceClient.h
Source/WebCore/page/DiagnosticLoggingKeys.cpp
Source/WebCore/page/DiagnosticLoggingKeys.h