WebKit Bugzilla
Attachment 368343 Details for
Bug 195623
: Link prefetch not useful for top-level navigation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-195623-20190426213354.patch (text/plain), 31.72 KB, created by
Rob Buis
on 2019-04-26 12:33:54 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2019-04-26 12:33:54 PDT
Size:
31.72 KB
patch
obsolete
>Subversion Revision: 244703 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 16396395a7ca0faba3ca0f94bc3f314eea7ca2c6..b2685da79d56de38241a888f0fa3ef36feb9eae5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-04-26 Rob Buis <rbuis@igalia.com> >+ >+ Link prefetch not useful for top-level navigation >+ https://bugs.webkit.org/show_bug.cgi?id=195623 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Cache cross-domain top-level prefetches in a dedicated cache and not in the >+ memory cache. >+ >+ Tests: http/tests/cache/link-prefetch-main-resource-iframe.html >+ http/tests/cache/link-prefetch-main-resource.html >+ http/tests/contentextensions/prefetch-blocked.html >+ >+ * loader/LinkLoader.cpp: >+ (WebCore::LinkLoader::prefetchIfNeeded): >+ * loader/ResourceLoadInfo.cpp: >+ (WebCore::toResourceType): >+ > 2019-04-26 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r244683. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 5c973d5666add9a5725e483bcc8380e9bc46d188..3774b98e910bce3c7295db5a22db82f8065b7639 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,42 @@ >+2019-04-26 Rob Buis <rbuis@igalia.com> >+ >+ Link prefetch not useful for top-level navigation >+ https://bugs.webkit.org/show_bug.cgi?id=195623 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Cache cross-domain top-level prefetches in a dedicated cache. When a navigation >+ to the same url is done within a threshold (5 seconds), reuse the >+ prefetch cache entry, move it to the disk cache and navigate to >+ the url, meaning no extra network trip is needed. When not used within >+ the threshold period, the prefetch entry will be erased using a timer. >+ >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::lowMemoryHandler): >+ * NetworkProcess/NetworkResourceLoader.cpp: >+ (WebKit::NetworkResourceLoader::retrieveCacheEntry): >+ (WebKit::NetworkResourceLoader::didReceiveResponse): >+ (WebKit::NetworkResourceLoader::didReceiveBuffer): >+ (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry): >+ (WebKit::NetworkResourceLoader::isCrossOriginPrefetch const): >+ * NetworkProcess/NetworkResourceLoader.h: >+ * NetworkProcess/NetworkSession.h: >+ (WebKit::NetworkSession::prefetchCache): >+ (WebKit::NetworkSession::clearPrefetchCache): >+ * NetworkProcess/cache/PrefetchCache.cpp: Added. >+ (WebKit::PrefetchCache::Entry::Entry): >+ (WebKit::PrefetchCache::PrefetchCache): >+ (WebKit::PrefetchCache::~PrefetchCache): >+ (WebKit::PrefetchCache::clear): >+ (WebKit::PrefetchCache::take): >+ (WebKit::PrefetchCache::store): >+ (WebKit::PrefetchCache::clearExpiredEntries): >+ * NetworkProcess/cache/PrefetchCache.h: Added. >+ (WebKit::PrefetchCache::Entry::releaseBuffer): >+ * Shared/WebPreferences.yaml: >+ * Sources.txt: >+ * WebKit.xcodeproj/project.pbxproj: >+ > 2019-04-26 Commit Queue <commit-queue@webkit.org> > > Unreviewed, rolling out r244683. >diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp >index 91861e1397eaafe9b2daf0f96d3adb5ca9050ba1..2cd76f9301a4ffc1f26a8e00be41571c0a881ad9 100644 >--- a/Source/WebCore/loader/LinkLoader.cpp >+++ b/Source/WebCore/loader/LinkLoader.cpp >@@ -277,8 +277,17 @@ void LinkLoader::prefetchIfNeeded(const LinkRelAttribute& relAttribute, const UR > m_cachedLinkResource->removeClient(*this); > m_cachedLinkResource = nullptr; > } >+ // FIXME: Add further prefetch restrictions/limitations: >+ // - third-party iframes cannot trigger prefetches >+ // - Number of prefetches of a given page is limited (to 1 maybe?) > ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions(); > options.contentSecurityPolicyImposition = ContentSecurityPolicyImposition::SkipPolicyCheck; >+ options.certificateInfoPolicy = CertificateInfoPolicy::IncludeCertificateInfo; >+ options.credentials = FetchOptions::Credentials::SameOrigin; >+ options.redirect = FetchOptions::Redirect::Manual; >+ options.mode = FetchOptions::Mode::Navigate; >+ options.serviceWorkersMode = ServiceWorkersMode::None; >+ options.cachingPolicy = CachingPolicy::DisallowCaching; > m_cachedLinkResource = document.cachedResourceLoader().requestLinkResource(type, CachedResourceRequest(ResourceRequest(document.completeURL(href)), options, priority)).value_or(nullptr); > if (m_cachedLinkResource) > m_cachedLinkResource->addClient(*this); >diff --git a/Source/WebCore/loader/ResourceLoadInfo.cpp b/Source/WebCore/loader/ResourceLoadInfo.cpp >index bf023b384fda98b7514971eb0ad156b28f28f68a..65a3edb4421d0505d0791a022b72da8f4a3baaa9 100644 >--- a/Source/WebCore/loader/ResourceLoadInfo.cpp >+++ b/Source/WebCore/loader/ResourceLoadInfo.cpp >@@ -37,6 +37,7 @@ namespace ContentExtensions { > ResourceType toResourceType(CachedResource::Type type) > { > switch (type) { >+ case CachedResource::Type::LinkPrefetch: > case CachedResource::Type::MainResource: > return ResourceType::Document; > case CachedResource::Type::SVGDocumentResource: >@@ -71,9 +72,6 @@ ResourceType toResourceType(CachedResource::Type type) > case CachedResource::Type::TextTrackResource: > return ResourceType::Media; > #endif >- case CachedResource::Type::LinkPrefetch: >- ASSERT_NOT_REACHED(); >- break; > #if ENABLE(APPLICATION_MANIFEST) > case CachedResource::Type::ApplicationManifest: > return ResourceType::Raw; >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 69226f0063ba4e37afbac685f92067ce67854b59..719be58823a036a84c2297e761b430aaf834fcd4 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -270,6 +270,9 @@ void NetworkProcess::lowMemoryHandler(Critical critical) > return; > > WTF::releaseFastMallocFreeMemory(); >+ >+ for (auto& networkSession : m_networkSessions.values()) >+ networkSession.get().clearPrefetchCache(); > } > > void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&& parameters) >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >index 048f077f90bbceb276d452c3e90e0ebaf2e373aa..beb1f8a7f166954ed6add1371773c4b6d41559ed 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp >@@ -211,6 +211,13 @@ void NetworkResourceLoader::retrieveCacheEntry(const ResourceRequest& request) > ASSERT(canUseCache(request)); > > RefPtr<NetworkResourceLoader> loader(this); >+ if (isMainFrameLoad()) { >+ ASSERT(m_parameters.options.mode == FetchOptions::Mode::Navigate); >+ if (auto session = m_connection->networkProcess().networkSession(sessionID())) { >+ if (auto entry = session->prefetchCache().take(request.url())) >+ m_cache->store(request, entry->response, entry->releaseBuffer(), nullptr); >+ } >+ } > m_cache->retrieve(request, { m_parameters.webPageID, m_parameters.webFrameID }, [this, loader = WTFMove(loader), request = ResourceRequest { request }](auto entry, auto info) mutable { > if (loader->hasOneRef()) { > // The loader has been aborted and is only held alive by this lambda. >@@ -469,6 +476,9 @@ void NetworkResourceLoader::didReceiveResponse(ResourceResponse&& receivedRespon > return completionHandler(PolicyAction::Use); > } > >+ if (isCrossOriginPrefetch()) >+ return completionHandler(PolicyAction::Use); >+ > // We wait to receive message NetworkResourceLoader::ContinueDidReceiveResponse before continuing a load for > // a main resource because the embedding client must decide whether to allow the load. > bool willWaitForContinueDidReceiveResponse = isMainResource(); >@@ -506,6 +516,8 @@ void NetworkResourceLoader::didReceiveBuffer(Ref<SharedBuffer>&& buffer, int rep > else > m_bufferedDataForCache = nullptr; > } >+ if (isCrossOriginPrefetch()) >+ return; > // FIXME: At least on OS X Yosemite we always get -1 from the resource handle. > unsigned encodedDataLength = reportedEncodedDataLength >= 0 ? reportedEncodedDataLength : buffer->size(); > >@@ -803,6 +815,11 @@ void NetworkResourceLoader::tryStoreAsCacheEntry() > if (!m_bufferedDataForCache) > return; > >+ if (isCrossOriginPrefetch()) { >+ if (auto session = m_connection->networkProcess().networkSession(sessionID())) >+ session->prefetchCache().store(m_networkLoad->currentRequest().url(), WTFMove(m_response), WTFMove(m_bufferedDataForCache)); >+ return; >+ } > m_cache->store(m_networkLoad->currentRequest(), m_response, WTFMove(m_bufferedDataForCache), [loader = makeRef(*this)](auto& mappedBody) mutable { > #if ENABLE(SHAREABLE_RESOURCE) > if (mappedBody.shareableResourceHandle.isNull()) >@@ -1133,6 +1150,12 @@ void NetworkResourceLoader::logSlowCacheRetrieveIfNeeded(const NetworkCache::Cac > #endif > } > >+bool NetworkResourceLoader::isCrossOriginPrefetch() const >+{ >+ auto request = originalRequest(); >+ return request.httpHeaderField(HTTPHeaderName::Purpose) == "prefetch" && !m_parameters.sourceOrigin->canRequest(request.url()); >+} >+ > } // namespace WebKit > > #undef RELEASE_LOG_IF_ALLOWED >diff --git a/Source/WebKit/NetworkProcess/NetworkResourceLoader.h b/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >index c7de3c0c1f3dd4ca9f73cfe00524e369a8224c0f..a8a3005c142306138876821a43a057a0b6f3d7fc 100644 >--- a/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >+++ b/Source/WebKit/NetworkProcess/NetworkResourceLoader.h >@@ -104,6 +104,7 @@ public: > > bool isMainResource() const { return m_parameters.request.requester() == WebCore::ResourceRequest::Requester::Main; } > bool isMainFrameLoad() const { return isMainResource() && m_parameters.frameAncestorOrigins.isEmpty(); } >+ bool isCrossOriginPrefetch() const; > > bool isAlwaysOnLoggingAllowed() const; > >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.h b/Source/WebKit/NetworkProcess/NetworkSession.h >index 7099db815dfdd455061b0a4443c44a09b1500fc6..442202b0ec61c763a51392a026a1aa90107ee8f1 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.h >+++ b/Source/WebKit/NetworkProcess/NetworkSession.h >@@ -25,6 +25,7 @@ > > #pragma once > >+#include "PrefetchCache.h" > #include "WebResourceLoadStatisticsStore.h" > #include <WebCore/AdClickAttribution.h> > #include <WebCore/RegistrableDomain.h> >@@ -92,6 +93,9 @@ public: > void addKeptAliveLoad(Ref<NetworkResourceLoader>&&); > void removeKeptAliveLoad(NetworkResourceLoader&); > >+ PrefetchCache& prefetchCache() { return m_prefetchCache; } >+ void clearPrefetchCache() { m_prefetchCache.clear(); } >+ > protected: > NetworkSession(NetworkProcess&, PAL::SessionID); > >@@ -108,6 +112,8 @@ protected: > UniqueRef<AdClickAttributionManager> m_adClickAttribution; > > HashSet<Ref<NetworkResourceLoader>> m_keptAliveLoads; >+ >+ PrefetchCache m_prefetchCache; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/cache/PrefetchCache.cpp b/Source/WebKit/NetworkProcess/cache/PrefetchCache.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..73cab47f91ee74241f232fffbe3f992df9c56cfc >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/cache/PrefetchCache.cpp >@@ -0,0 +1,99 @@ >+/* >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "PrefetchCache.h" >+ >+#include <WebCore/HTTPHeaderNames.h> >+ >+namespace WebKit { >+ >+PrefetchCache::Entry::Entry(WebCore::ResourceResponse&& response, RefPtr<WebCore::SharedBuffer>&& buffer) >+ : response(WTFMove(response)), buffer(WTFMove(buffer)) >+{ >+} >+ >+PrefetchCache::PrefetchCache() >+ : m_expirationTimer(*this, &PrefetchCache::clearExpiredEntries) >+{ >+} >+ >+PrefetchCache::~PrefetchCache() >+{ >+} >+ >+void PrefetchCache::clear() >+{ >+ m_expirationTimer.stop(); >+ m_sessionExpirationList.clear(); >+ if (m_sessionPrefetches) >+ m_sessionPrefetches->clear(); >+} >+ >+std::unique_ptr<PrefetchCache::Entry> PrefetchCache::take(const URL& url) >+{ >+ auto* resources = m_sessionPrefetches.get(); >+ if (!resources) >+ return nullptr; >+ m_sessionExpirationList.removeAllMatching([&url] (const auto& tuple) { >+ return std::get<0>(tuple) == url; >+ }); >+ return resources->take(url); >+} >+ >+static const Seconds expirationTimeout { 5_s }; >+ >+void PrefetchCache::store(const URL& requestUrl, WebCore::ResourceResponse&& response, RefPtr<WebCore::SharedBuffer>&& buffer) >+{ >+ if (!m_sessionPrefetches) >+ m_sessionPrefetches = std::make_unique<PrefetchEntriesMap>(); >+ m_sessionPrefetches->set(requestUrl, std::make_unique<PrefetchCache::Entry>(WTFMove(response), WTFMove(buffer))); >+ m_sessionExpirationList.append(std::make_tuple(requestUrl, WallTime::now())); >+ if (!m_expirationTimer.isActive()) >+ m_expirationTimer.startOneShot(expirationTimeout); >+} >+ >+void PrefetchCache::clearExpiredEntries() >+{ >+ URL requestUrl; >+ WallTime timestamp; >+ auto timeout = WallTime::now(); >+ while (!m_sessionExpirationList.isEmpty()) { >+ std::tie(requestUrl, timestamp) = m_sessionExpirationList.first(); >+ auto* resources = m_sessionPrefetches.get(); >+ ASSERT(resources); >+ ASSERT(resources->contains(requestUrl)); >+ auto elapsed = timeout - timestamp; >+ if (elapsed > expirationTimeout) { >+ resources->remove(requestUrl); >+ m_sessionExpirationList.removeFirst(); >+ } else { >+ m_expirationTimer.startOneShot(expirationTimeout - elapsed); >+ break; >+ } >+ } >+} >+ >+} >diff --git a/Source/WebKit/NetworkProcess/cache/PrefetchCache.h b/Source/WebKit/NetworkProcess/cache/PrefetchCache.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c8895fe24b76f8d04adb638c73b1a1c84b2a9c40 >--- /dev/null >+++ b/Source/WebKit/NetworkProcess/cache/PrefetchCache.h >@@ -0,0 +1,71 @@ >+/* >+ * Copyright (C) 2019 Igalia S.L. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <WebCore/ResourceResponse.h> >+#include <WebCore/SharedBuffer.h> >+#include <WebCore/Timer.h> >+#include <wtf/Deque.h> >+#include <wtf/HashMap.h> >+#include <wtf/URLHash.h> >+#include <wtf/text/WTFString.h> >+ >+namespace WebKit { >+ >+class PrefetchCache { >+ WTF_MAKE_NONCOPYABLE(PrefetchCache); >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ PrefetchCache(); >+ ~PrefetchCache(); >+ >+ void clear(); >+ >+ struct Entry { >+ Entry(WebCore::ResourceResponse&&, RefPtr<WebCore::SharedBuffer>&&); >+ >+ Ref<WebCore::SharedBuffer> releaseBuffer() { return buffer.releaseNonNull(); } >+ >+ WebCore::ResourceResponse response; >+ RefPtr<WebCore::SharedBuffer> buffer; >+ }; >+ >+ std::unique_ptr<Entry> take(const URL&); >+ void store(const URL&, WebCore::ResourceResponse&&, RefPtr<WebCore::SharedBuffer>&&); >+ >+private: >+ void clearExpiredEntries(); >+ >+ using PrefetchEntriesMap = HashMap<URL, std::unique_ptr<Entry>>; >+ std::unique_ptr<PrefetchEntriesMap> m_sessionPrefetches; >+ >+ using SessionPrefetchExpirationList = Deque<std::tuple<URL, WallTime>>; >+ SessionPrefetchExpirationList m_sessionExpirationList; >+ >+ WebCore::Timer m_expirationTimer; >+}; >+ >+} // namespace WebKit >diff --git a/Source/WebKit/Shared/WebPreferences.yaml b/Source/WebKit/Shared/WebPreferences.yaml >index ff9da3b51ae89d7bf38f5f9cd8116fb81b711c1c..04bfc5f7742e9e59b3ac175adbbbc5671840e67c 100644 >--- a/Source/WebKit/Shared/WebPreferences.yaml >+++ b/Source/WebKit/Shared/WebPreferences.yaml >@@ -1650,6 +1650,14 @@ ApplePayRemoteUIEnabled: > humanReadableName: "Apple Pay Remote UI" > type: bool > >+LinkPrefetchEnabled: >+ type: bool >+ defaultValue: false >+ humanReadableName: "LinkPrefetch" >+ humanReadableDescription: "Enable LinkedPrefetch" >+ webcoreBinding: RuntimeEnabledFeatures >+ category: experimental >+ > # Deprecated > > ICECandidateFilteringEnabled: >diff --git a/Source/WebKit/Sources.txt b/Source/WebKit/Sources.txt >index 799c6f0a6f4927fcd74ac087ae9ef30121ca1f5d..48f58e3c243b87ad36ff2d84e0d9660cdd4289d9 100644 >--- a/Source/WebKit/Sources.txt >+++ b/Source/WebKit/Sources.txt >@@ -80,6 +80,7 @@ NetworkProcess/cache/NetworkCacheSpeculativeLoad.cpp > NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp > NetworkProcess/cache/NetworkCacheStorage.cpp > NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp >+NetworkProcess/cache/PrefetchCache.cpp > > NetworkProcess/webrtc/NetworkMDNSRegister.cpp > >diff --git a/Source/WebKit/WebKit.xcodeproj/project.pbxproj b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >index 8eec4323b4985c223994e11debde6c526e718826..6fb803959cbe1c056b5550aa89945f155326f00d 100644 >--- a/Source/WebKit/WebKit.xcodeproj/project.pbxproj >+++ b/Source/WebKit/WebKit.xcodeproj/project.pbxproj >@@ -1333,6 +1333,7 @@ > A78CCDDB193AC9F8005ECC25 /* com.apple.WebKit.Networking.sb in CopyFiles */ = {isa = PBXBuildFile; fileRef = A78CCDD8193AC9E3005ECC25 /* com.apple.WebKit.Networking.sb */; }; > A78CCDDC193AC9FB005ECC25 /* com.apple.WebKit.WebContent.sb in CopyFiles */ = {isa = PBXBuildFile; fileRef = A78CCDD9193AC9E3005ECC25 /* com.apple.WebKit.WebContent.sb */; }; > A7D792D81767CCA300881CBE /* ActivityAssertion.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D792D41767CB0900881CBE /* ActivityAssertion.h */; }; >+ AAB145E6223F931200E489D8 /* PrefetchCache.h in Headers */ = {isa = PBXBuildFile; fileRef = AAB145E4223F931200E489D8 /* PrefetchCache.h */; }; > B62E7312143047B00069EC35 /* WKHitTestResult.h in Headers */ = {isa = PBXBuildFile; fileRef = B62E7311143047B00069EC35 /* WKHitTestResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; > B878B615133428DC006888E9 /* CorrectionPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = B878B613133428DC006888E9 /* CorrectionPanel.h */; }; > BC017D0716260FF4007054F5 /* WKDOMDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = BC017CFF16260FF4007054F5 /* WKDOMDocument.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -3994,6 +3995,8 @@ > A7D792D41767CB0900881CBE /* ActivityAssertion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ActivityAssertion.h; sourceTree = "<group>"; }; > A7D792D51767CB6E00881CBE /* ActivityAssertion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ActivityAssertion.cpp; sourceTree = "<group>"; }; > A7E93CEB192531AA00A1DC48 /* AuxiliaryProcessIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AuxiliaryProcessIOS.mm; path = ios/AuxiliaryProcessIOS.mm; sourceTree = "<group>"; }; >+ AAB145E4223F931200E489D8 /* PrefetchCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrefetchCache.h; sourceTree = "<group>"; }; >+ AAB145E5223F931200E489D8 /* PrefetchCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrefetchCache.cpp; sourceTree = "<group>"; }; > B396EA5512E0ED2D00F4FEB7 /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; }; > B62E730F143047A60069EC35 /* WKHitTestResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKHitTestResult.cpp; sourceTree = "<group>"; }; > B62E7311143047B00069EC35 /* WKHitTestResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKHitTestResult.h; sourceTree = "<group>"; }; >@@ -8958,6 +8961,8 @@ > E4436EC21A0CFDB200EAD204 /* NetworkCacheStorage.h */, > 8310428A1BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.cpp */, > 831042891BD6B66F00A715E4 /* NetworkCacheSubresourcesEntry.h */, >+ AAB145E5223F931200E489D8 /* PrefetchCache.cpp */, >+ AAB145E4223F931200E489D8 /* PrefetchCache.h */, > ); > path = cache; > sourceTree = "<group>"; >@@ -9435,6 +9440,7 @@ > 7CD622781739D863005BD7FF /* PluginSandboxProfile.h in Headers */, > 1A6FB7AF11E64B6800DB1371 /* PluginView.h in Headers */, > 83A0ED351F747CCF003299EB /* PreconnectTask.h in Headers */, >+ AAB145E6223F931200E489D8 /* PrefetchCache.h in Headers */, > E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */, > 86F9536518FF58F5001DB2EF /* ProcessAssertion.h in Headers */, > BC1A7C581136E19C00FB7167 /* ProcessLauncher.h in Headers */, >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 52b7b788d46ddc52093166a779abaf47d92a7e4c..2dc5f39b3d2b1a40deb033706be0723726303b1d 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,26 @@ >+2019-04-26 Rob Buis <rbuis@igalia.com> >+ >+ Link prefetch not useful for top-level navigation >+ https://bugs.webkit.org/show_bug.cgi?id=195623 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Verify that prefetching a cross-domain top-level main resource >+ is cached in the prefetch cache and only loaded once, and that non >+ top-level prefetches keep the old behavior. >+ >+ * http/tests/cache/link-prefetch-main-resource-expected.txt: Added. >+ * http/tests/cache/link-prefetch-main-resource-iframe-expected.txt: Added. >+ * http/tests/cache/link-prefetch-main-resource-iframe.html: Added. >+ * http/tests/cache/link-prefetch-main-resource.html: Added. >+ * http/tests/cache/resources/prefetched-main-resource-iframe.php: Added. >+ * http/tests/cache/resources/prefetched-main-resource.php: Added. >+ * http/tests/contentextensions/prefetch-blocked-expected.txt: Added. >+ * http/tests/contentextensions/prefetch-blocked.html: Added. >+ * http/tests/contentextensions/prefetch-blocked.html.json: Added. >+ * platform/mac-wk1/TestExpectations: >+ * platform/win/TestExpectations: >+ > 2019-04-26 Youenn Fablet <youenn@apple.com> > > Use normal loading path for ping loads >diff --git a/LayoutTests/http/tests/cache/link-prefetch-main-resource-expected.txt b/LayoutTests/http/tests/cache/link-prefetch-main-resource-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..7ef22e9a431ad0272713b71fdc8794016c8ef12f >--- /dev/null >+++ b/LayoutTests/http/tests/cache/link-prefetch-main-resource-expected.txt >@@ -0,0 +1 @@ >+PASS >diff --git a/LayoutTests/http/tests/cache/link-prefetch-main-resource-iframe-expected.txt b/LayoutTests/http/tests/cache/link-prefetch-main-resource-iframe-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..69cfc5a98db74fbe32ac9b678a6134af9736dd59 >--- /dev/null >+++ b/LayoutTests/http/tests/cache/link-prefetch-main-resource-iframe-expected.txt >@@ -0,0 +1,2 @@ >+PASS >+ >diff --git a/LayoutTests/http/tests/cache/link-prefetch-main-resource-iframe.html b/LayoutTests/http/tests/cache/link-prefetch-main-resource-iframe.html >new file mode 100644 >index 0000000000000000000000000000000000000000..44366f5923c2e2f69941a8d45aceb1a342512bc3 >--- /dev/null >+++ b/LayoutTests/http/tests/cache/link-prefetch-main-resource-iframe.html >@@ -0,0 +1,38 @@ >+<html> >+<body> >+<div id="result"></div> >+<script> >+ >+if (window.testRunner) { >+ testRunner.dumpAsText(); >+ testRunner.waitUntilDone(); >+} >+ >+function done() >+{ >+ testRunner.notifyDone(); >+} >+ >+function iframeLoadFinished() >+{ >+ if (window.testRunner) >+ setTimeout(done, 0); >+} >+ >+function loadAfterPrefetch() >+{ >+ var newIframe = document.createElement("iframe"); >+ newIframe.src = "http://localhost:8000/cache/resources/prefetched-main-resource-iframe.php"; >+ newIframe.onload = iframeLoadFinished; >+ document.body.appendChild(newIframe); >+} >+ >+window.onmessage = function(message) >+{ >+ document.getElementById('result').textContent = message.data; >+} >+ >+</script> >+<link rel="prefetch" href="http://localhost:8000/cache/resources/prefetched-main-resource-iframe.php" onload="setTimeout(loadAfterPrefetch, 0);"> >+</body> >+</html> >diff --git a/LayoutTests/http/tests/cache/link-prefetch-main-resource.html b/LayoutTests/http/tests/cache/link-prefetch-main-resource.html >new file mode 100644 >index 0000000000000000000000000000000000000000..7420df575559ceb866c9751955a26005e21a14a2 >--- /dev/null >+++ b/LayoutTests/http/tests/cache/link-prefetch-main-resource.html >@@ -0,0 +1,16 @@ >+<html> >+<script> >+if (window.testRunner) { >+ testRunner.waitUntilDone(); >+ testRunner.dumpAsText(); >+} >+ >+function loadAfterPrefetch() >+{ >+ window.location.assign('http://localhost:8000/cache/resources/prefetched-main-resource.php'); >+} >+</script> >+<body> >+<link rel="prefetch" href="http://localhost:8000/cache/resources/prefetched-main-resource.php" onload="loadAfterPrefetch();"> >+</body> >+</html> >diff --git a/LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php b/LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php >new file mode 100644 >index 0000000000000000000000000000000000000000..a7ad2e9754f1964690e8c8232c2a2fa146b8bc56 >--- /dev/null >+++ b/LayoutTests/http/tests/cache/resources/prefetched-main-resource-iframe.php >@@ -0,0 +1,18 @@ >+<?php >+if ($_SERVER["HTTP_PURPOSE"] == "prefetch") { >+ header('Cache-Control: max-age=3600'); >+ header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); >+ >+ echo "<script>"; >+ echo "parent.window.postMessage('FAIL', '*');"; >+ echo "</script>"; >+ >+ exit(); >+} >+ >+header("Access-Control-Allow-Origin: http://127.0.0.1:8000"); >+ >+echo "<script>"; >+echo "parent.window.postMessage('PASS', '*');"; >+echo "</script>"; >+?> >diff --git a/LayoutTests/http/tests/cache/resources/prefetched-main-resource.php b/LayoutTests/http/tests/cache/resources/prefetched-main-resource.php >new file mode 100644 >index 0000000000000000000000000000000000000000..7a3ceb47c5f168909450e97df842d3b2573bbc1d >--- /dev/null >+++ b/LayoutTests/http/tests/cache/resources/prefetched-main-resource.php >@@ -0,0 +1,21 @@ >+<?php >+header('Cache-Control: max-age=3600'); >+?> >+<!DOCTYPE html> >+<html> >+<body> >+<script> >+ >+if (window.testRunner) >+ testRunner.notifyDone(); >+ >+</script> >+<?php >+if ($_SERVER["HTTP_PURPOSE"] == "prefetch") { >+ print('PASS'); >+} else { >+ print('FAIL'); >+} >+?> >+</body> >+</html> >diff --git a/LayoutTests/http/tests/contentextensions/prefetch-blocked-expected.txt b/LayoutTests/http/tests/contentextensions/prefetch-blocked-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..362195b87bb6d42692dc0f3f8f768e5f65b7a4cf >--- /dev/null >+++ b/LayoutTests/http/tests/contentextensions/prefetch-blocked-expected.txt >@@ -0,0 +1,4 @@ >+CONSOLE MESSAGE: line 8: Content blocker prevented frame displaying http://127.0.0.1:8000/contentextensions/resources/should-not-load.html from loading a resource from http://127.0.0.1:8000/contentextensions/resources/should-not-load.html >+This page prefetches a Document. >+The prefetch should be blocked by the content extension filter >+ >diff --git a/LayoutTests/http/tests/contentextensions/prefetch-blocked.html b/LayoutTests/http/tests/contentextensions/prefetch-blocked.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d7d464ac5c3354e06f275d4c5a8adaef194748e0 >--- /dev/null >+++ b/LayoutTests/http/tests/contentextensions/prefetch-blocked.html >@@ -0,0 +1,8 @@ >+This page prefetches a Document.<br> >+The prefetch should be blocked by the content extension filter<br> >+<script> >+if (window.testRunner) { >+ testRunner.dumpAsText(); >+} >+</script> >+<link rel="prefetch" href="resources/should-not-load.html"> >diff --git a/LayoutTests/http/tests/contentextensions/prefetch-blocked.html.json b/LayoutTests/http/tests/contentextensions/prefetch-blocked.html.json >new file mode 100644 >index 0000000000000000000000000000000000000000..4785329737a2d5becc3667a3b508bd825ff9a1a2 >--- /dev/null >+++ b/LayoutTests/http/tests/contentextensions/prefetch-blocked.html.json >@@ -0,0 +1,11 @@ >+[ >+ { >+ "action": { >+ "type": "block" >+ }, >+ "trigger": { >+ "url-filter": "should-not-load", >+ "resource-type": ["document"] >+ } >+ } >+] >diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations >index 18511a196346a7dfea0a1970f84f6da500c4c5a5..155ca4839694879b52fc98927ab6a2da632b1b15 100644 >--- a/LayoutTests/platform/mac-wk1/TestExpectations >+++ b/LayoutTests/platform/mac-wk1/TestExpectations >@@ -705,3 +705,6 @@ webkit.org/b/196448 [ Debug ] inspector/audit/basic.html [ Pass Timeout ] > webkit.org/b/196502 media/video-background-tab-playback.html [ Pass Failure ] > > webkit.org/b/196915 [ Debug ] inspector/timeline/timeline-recording.html [ Pass Failure ] >+ >+webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ] >+webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ] >diff --git a/LayoutTests/platform/win/TestExpectations b/LayoutTests/platform/win/TestExpectations >index 450805b64508e9db49857ef927564547201acbad..eb5d332ddd16ecc989abaaa0e513f773a7a4c04a 100644 >--- a/LayoutTests/platform/win/TestExpectations >+++ b/LayoutTests/platform/win/TestExpectations >@@ -4335,3 +4335,6 @@ webkit.org/b/196869 imported/mozilla/css-animations/test_animation-currenttime.h > webkit.org/b/194450 storage/indexeddb/modern/gc-closes-database-private.html [ Skip ] > > webkit.org/b/197310 fast/harness/render-tree-as-text-options.html [ Failure ] >+ >+webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource.html [ Skip ] >+webkit.org/b/195623 http/tests/cache/link-prefetch-main-resource-iframe.html [ Skip ]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 195623
:
364392
|
364402
|
364415
|
364419
|
364687
|
364704
|
364708
|
364712
|
364725
|
364761
|
365017
|
365023
|
365024
|
365030
|
365040
|
365045
|
365058
|
365101
|
365173
|
365183
|
365194
|
365198
|
365223
|
365235
|
365248
|
365253
|
365265
|
365334
|
365340
|
365342
|
365401
|
365460
|
365546
|
365562
|
365591
|
365649
|
365697
|
365700
|
365705
|
365869
|
365880
|
365881
|
365987
|
366000
|
366057
|
366069
|
366266
|
366273
|
366278
|
366280
|
366281
|
366476
|
366479
|
366481
|
366488
|
366585
|
366586
|
366602
|
367385
|
367388
|
367404
|
367534
|
367804
|
367891
|
367932
|
368016
|
368124
|
368129
|
368134
|
368136
|
368137
|
368311
|
368313
|
368317
|
368326
|
368343
|
369372