WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-162281-20161011121748.patch (text/plain), 50.17 KB, created by
youenn fablet
on 2016-10-11 03:21:12 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2016-10-11 03:21:12 PDT
Size:
50.17 KB
patch
obsolete
>Subversion Revision: 207060 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 8dcede1d92323e90976b1e854af6c10a1a4d185a..0414f0521ba5780a2a73d09075990aaabdcb94da 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,50 @@ >+2016-10-11 Youenn Fablet <youenn@apple.com> >+ >+ [Fetch API] Support Request cache mode >+ https://bugs.webkit.org/show_bug.cgi?id=162281 >+ >+ Reviewed by Alex Christensen. >+ >+ Covered by updated test. >+ >+ Added support for only-if-cached mode at Request level. >+ >+ Added support for cache mode at CachedResourceLoader, by setting HTTP headers and ResourceRequest cache policy >+ based on https://fetch.spec.whatwg.org/#concept-request-cache-mode and https://fetch.spec.whatwg.org/#http-network-or-cache-fetch. >+ >+ Disabled default cache policy computation (done in FrameLoader) when cache mode is different from the default. >+ Activated no-store cache mode for EventSource as per https://html.spec.whatwg.org/#the-eventsource-interface. >+ >+ * Modules/fetch/FetchRequest.cpp: >+ (WebCore::setCache): Adding support for only-if-cached. >+ (WebCore::buildOptions): Throw if only-if-cached and fetch mode is not same-origin. >+ * loader/FetchOptions.h: Adding support for only-if-cached. >+ * loader/FrameLoader.cpp: >+ (WebCore::FrameLoader::defaultRequestCachingPolicy): Introduced to ease readability. >+ (WebCore::FrameLoader::addExtraFieldsToRequest): Updating cache policy only if request has the default cache policy. >+ This allows bypassing the default behavior for fetch cache mode different from "default". >+ * loader/FrameLoader.h: >+ * loader/cache/CachedResourceLoader.cpp: >+ (WebCore::updateRequestAccordingCacheMode): Introduced to set headers and request cache policy according fetch cache mode. >+ (WebCore::CachedResourceLoader::requestResource): >+ (WebCore::CachedResourceLoader::loadResource): >+ (WebCore::CachedResourceLoader::determineRevalidationPolicy): Ensure bypassing the memory cache in no-store and reload cases. >+ We reload in case of cache mode=reload to refresh the meory cache entry. >+ * loader/cache/CachedResourceRequest.h: >+ (WebCore::CachedResourceRequest::setCacheModeToNoStore): >+ * page/EventSource.cpp: >+ (WebCore::EventSource::connect): Use no-store cache mode as per https://html.spec.whatwg.org/#the-eventsource-interface. >+ * platform/network/HTTPHeaderMap.cpp: >+ (WebCore::HTTPHeaderMap::addIfNotPresent): Helper routine. >+ * platform/network/HTTPHeaderMap.h: >+ * platform/network/HTTPHeaderValues.cpp: >+ * platform/network/HTTPHeaderValues.h: >+ * platform/network/ResourceRequestBase.cpp: >+ (WebCore::ResourceRequestBase::addHTTPHeaderFieldIfNotPresent): >+ (WebCore::ResourceRequestBase::addHTTPHeaderField): >+ (WebCore::ResourceRequestBase::hasHTTPHeaderField): >+ * platform/network/ResourceRequestBase.h: >+ > 2016-10-11 Chris Dumez <cdumez@apple.com> > > Update IDBVersionChangeEvent to stop using legacy [ConstructorTemplate=Event] >diff --git a/Source/WebCore/Modules/fetch/FetchRequest.cpp b/Source/WebCore/Modules/fetch/FetchRequest.cpp >index 60e3e7b8a23e721804dbd9f20f36b4baec34203d..9afccb87f7a6d36f34a99a0d4c60c954072c476e 100644 >--- a/Source/WebCore/Modules/fetch/FetchRequest.cpp >+++ b/Source/WebCore/Modules/fetch/FetchRequest.cpp >@@ -98,6 +98,8 @@ static Optional<Exception> setCache(FetchOptions& options, const String& cache) > options.cache = FetchOptions::Cache::NoCache; > else if (cache == "force-cache") > options.cache = FetchOptions::Cache::ForceCache; >+ else if (cache == "only-if-cached") >+ options.cache = FetchOptions::Cache::OnlyIfCached; > else > return Exception { TypeError, ASCIILiteral("Bad cache mode value.") }; > return Nullopt; >@@ -195,6 +197,9 @@ static Optional<Exception> buildOptions(FetchRequest::InternalRequest& request, > return exception; > } > >+ if (request.options.cache == FetchOptions::Cache::OnlyIfCached && request.options.mode != FetchOptions::Mode::SameOrigin) >+ return Exception { TypeError, ASCIILiteral("only-if-cached cache option requires fetch mode to be same-origin.") }; >+ > if (init.get("redirect", value)) { > exception = setRedirect(request.options, value); > if (exception) >diff --git a/Source/WebCore/loader/FetchOptions.h b/Source/WebCore/loader/FetchOptions.h >index 499c81b5a442c5550c2d84d460015b644ebe7e77..b733461c64bcb79d5e216f9ca54aa9c38db14468 100644 >--- a/Source/WebCore/loader/FetchOptions.h >+++ b/Source/WebCore/loader/FetchOptions.h >@@ -43,7 +43,7 @@ struct FetchOptions { > enum class Credentials { Omit, SameOrigin, Include }; > Credentials credentials { Credentials::Omit }; > >- enum class Cache { Default, NoStore, Reload, NoCache, ForceCache }; >+ enum class Cache { Default, NoStore, Reload, NoCache, ForceCache, OnlyIfCached }; > Cache cache { Cache::Default }; > > enum class Redirect { Follow, Error, Manual }; >diff --git a/Source/WebCore/loader/FrameLoader.cpp b/Source/WebCore/loader/FrameLoader.cpp >index 81ed14bbf2eed8b681dacc422f1ec2a3bd4ac412..20a82adfae536cc54e58aaa380f58ec0de4a08a4 100644 >--- a/Source/WebCore/loader/FrameLoader.cpp >+++ b/Source/WebCore/loader/FrameLoader.cpp >@@ -2562,36 +2562,14 @@ void FrameLoader::addExtraFieldsToMainResourceRequest(ResourceRequest& request) > addHTTPUpgradeInsecureRequestsIfNeeded(request); > } > >-void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadType loadType, bool mainResource) >+ResourceRequestCachePolicy FrameLoader::defaultRequestCachingPolicy(const ResourceRequest& request, FrameLoadType loadType, bool isMainResource) > { >- Page* page = frame().page(); >- bool cachingDisabled = page && page->isResourceCachingDisabled(); >- >- if (cachingDisabled) >- request.setCachePolicy(ReloadIgnoringCacheData); >- >- // Don't set the cookie policy URL if it's already been set. >- // But make sure to set it on all requests regardless of protocol, as it has significance beyond the cookie policy (<rdar://problem/6616664>). >- if (request.firstPartyForCookies().isEmpty()) { >- if (mainResource && m_frame.isMainFrame()) >- request.setFirstPartyForCookies(request.url()); >- else if (Document* document = m_frame.document()) >- request.setFirstPartyForCookies(document->firstPartyForCookies()); >- } >- >- // The remaining modifications are only necessary for HTTP and HTTPS. >- if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) >- return; >- >- applyUserAgent(request); >- >- if (cachingDisabled) { >- // Cache policy was already set above in the non-HTTP-specific code. >- loadType = FrameLoadType::ReloadFromOrigin; >- } else if (!mainResource) { >+ if (m_overrideCachePolicyForTesting) >+ return m_overrideCachePolicyForTesting.value(); >+ if (!isMainResource) { > if (request.isConditional()) >- request.setCachePolicy(ReloadIgnoringCacheData); >- else if (documentLoader()->isLoadingInAPISense()) { >+ return ReloadIgnoringCacheData; >+ if (documentLoader()->isLoadingInAPISense()) { > // If we inherit cache policy from a main resource, we use the DocumentLoader's > // original request cache policy for two reasons: > // 1. For POST requests, we mutate the cache policy for the main resource, >@@ -2602,22 +2580,41 @@ void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp > ResourceRequestCachePolicy mainDocumentOriginalCachePolicy = documentLoader()->originalRequest().cachePolicy(); > // Back-forward navigations try to load main resource from cache only to avoid re-submitting form data, and start over (with a warning dialog) if that fails. > // This policy is set on initial request too, but should not be inherited. >- ResourceRequestCachePolicy subresourceCachePolicy = (mainDocumentOriginalCachePolicy == ReturnCacheDataDontLoad) ? ReturnCacheDataElseLoad : mainDocumentOriginalCachePolicy; >- request.setCachePolicy(subresourceCachePolicy); >- } else >- request.setCachePolicy(UseProtocolCachePolicy); >- >+ return (mainDocumentOriginalCachePolicy == ReturnCacheDataDontLoad) ? ReturnCacheDataElseLoad : mainDocumentOriginalCachePolicy; >+ } > // FIXME: Other FrameLoader functions have duplicated code for setting cache policy of main request when reloading. > // It seems better to manage it explicitly than to hide the logic inside addExtraFieldsToRequest(). > } else if (loadType == FrameLoadType::Reload || loadType == FrameLoadType::ReloadFromOrigin || request.isConditional()) >+ return ReloadIgnoringCacheData; >+ >+ return UseProtocolCachePolicy; >+} >+ >+void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadType loadType, bool isMainResource) >+{ >+ // Don't set the cookie policy URL if it's already been set. >+ // But make sure to set it on all requests regardless of protocol, as it has significance beyond the cookie policy (<rdar://problem/6616664>). >+ if (request.firstPartyForCookies().isEmpty()) { >+ if (isMainResource && m_frame.isMainFrame()) >+ request.setFirstPartyForCookies(request.url()); >+ else if (Document* document = m_frame.document()) >+ request.setFirstPartyForCookies(document->firstPartyForCookies()); >+ } >+ >+ Page* page = frame().page(); >+ bool hasSpecificCachePolicy = request.cachePolicy() != UseProtocolCachePolicy; >+ >+ if (page && page->isResourceCachingDisabled()) { > request.setCachePolicy(ReloadIgnoringCacheData); >+ loadType = FrameLoadType::ReloadFromOrigin; >+ } else if (!hasSpecificCachePolicy) >+ request.setCachePolicy(defaultRequestCachingPolicy(request, loadType, isMainResource)); > >- if (m_overrideCachePolicyForTesting) >- request.setCachePolicy(m_overrideCachePolicyForTesting.value()); >- if (m_overrideResourceLoadPriorityForTesting) >- request.setPriority(m_overrideResourceLoadPriorityForTesting.value()); >+ // The remaining modifications are only necessary for HTTP and HTTPS. >+ if (!request.url().isEmpty() && !request.url().protocolIsInHTTPFamily()) >+ return; > >- if (request.cachePolicy() == ReloadIgnoringCacheData) { >+ if (!hasSpecificCachePolicy && request.cachePolicy() == ReloadIgnoringCacheData) { > if (loadType == FrameLoadType::Reload) > request.setHTTPHeaderField(HTTPHeaderName::CacheControl, "max-age=0"); > else if (loadType == FrameLoadType::ReloadFromOrigin) { >@@ -2626,7 +2623,12 @@ void FrameLoader::addExtraFieldsToRequest(ResourceRequest& request, FrameLoadTyp > } > } > >- if (mainResource) >+ if (m_overrideResourceLoadPriorityForTesting) >+ request.setPriority(m_overrideResourceLoadPriorityForTesting.value()); >+ >+ applyUserAgent(request); >+ >+ if (isMainResource) > request.setHTTPAccept(defaultAcceptHeader); > > // Make sure we send the Origin header. >diff --git a/Source/WebCore/loader/FrameLoader.h b/Source/WebCore/loader/FrameLoader.h >index 601478c164f4e6e6443ab154f86af4f422506f52..614e526c90f2aa9cb9985ec97cec4b493de8c88d 100644 >--- a/Source/WebCore/loader/FrameLoader.h >+++ b/Source/WebCore/loader/FrameLoader.h >@@ -311,16 +311,17 @@ private: > bool allChildrenAreComplete() const; // immediate children, not all descendants > > void checkTimerFired(); >- >+ > void loadSameDocumentItem(HistoryItem&); > void loadDifferentDocumentItem(HistoryItem&, FrameLoadType, FormSubmissionCacheLoadPolicy); >- >+ > void loadProvisionalItemFromCachedPage(); > > void updateFirstPartyForCookies(); > void setFirstPartyForCookies(const URL&); >- >+ > void addExtraFieldsToRequest(ResourceRequest&, FrameLoadType, bool isMainResource); >+ ResourceRequestCachePolicy defaultRequestCachingPolicy(const ResourceRequest&, FrameLoadType, bool isMainResource); > > void clearProvisionalLoad(); > void transitionToCommitted(CachedPage*); >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >index 210910d8fcebb5c0ccf98bd95a0d95e522554523..f1fab22e69a0bff99dbe7d77217e004b58c8abd7 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >@@ -51,6 +51,7 @@ > #include "FrameLoaderClient.h" > #include "HTMLElement.h" > #include "HTMLFrameOwnerElement.h" >+#include "HTTPHeaderValues.h" > #include "LoaderStrategy.h" > #include "LocalizedStrings.h" > #include "Logging.h" >@@ -663,6 +664,49 @@ void CachedResourceLoader::prepareFetch(CachedResource::Type type, CachedResourc > // FIXME: Decide whether to support client hints > } > >+static inline void updateRequestAccordingCacheMode(CachedResourceRequest& request) >+{ >+ if (request.options().cache == FetchOptions::Cache::Default >+ && (request.resourceRequest().hasHTTPHeaderField(HTTPHeaderName::IfModifiedSince) >+ || request.resourceRequest().hasHTTPHeaderField(HTTPHeaderName::IfNoneMatch) >+ || request.resourceRequest().hasHTTPHeaderField(HTTPHeaderName::IfUnmodifiedSince) >+ || request.resourceRequest().hasHTTPHeaderField(HTTPHeaderName::IfMatch) >+ || request.resourceRequest().hasHTTPHeaderField(HTTPHeaderName::IfRange))) >+ request.setCacheModeToNoStore(); >+ >+ switch (request.options().cache) { >+ case FetchOptions::Cache::NoCache: >+ request.mutableResourceRequest().setCachePolicy(ReloadIgnoringCacheData); >+ request.mutableResourceRequest().addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0()); >+ break; >+ case FetchOptions::Cache::NoStore: >+ request.setCachingPolicy(CachingPolicy::DisallowCaching); >+ request.mutableResourceRequest().setCachePolicy(ReloadIgnoringCacheData); >+ request.mutableResourceRequest().addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache()); >+ request.mutableResourceRequest().addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache()); >+ break; >+ case FetchOptions::Cache::Reload: >+ request.mutableResourceRequest().setCachePolicy(ReloadIgnoringCacheData); >+ request.mutableResourceRequest().addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache()); >+ request.mutableResourceRequest().addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache()); >+ break; >+ case FetchOptions::Cache::Default: >+ break; >+ case FetchOptions::Cache::ForceCache: >+ request.mutableResourceRequest().setCachePolicy(ReturnCacheDataElseLoad); >+ break; >+ case FetchOptions::Cache::OnlyIfCached: >+ request.mutableResourceRequest().setCachePolicy(ReturnCacheDataDontLoad); >+ break; >+ } >+} >+ >+void CachedResourceLoader::updateHTTPRequestHeaders(CachedResourceRequest& resourceRequest) >+{ >+ // Implementing steps 10 to 12 of https://fetch.spec.whatwg.org/#http-network-or-cache-fetch >+ updateRequestAccordingCacheMode(resourceRequest); >+} >+ > CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer) > { > if (Document* document = this->document()) >@@ -720,6 +764,9 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(Cache > loadTiming.markStartTimeAndFetchStart(); > #endif > >+ if (request.resourceRequest().url().protocolIsInHTTPFamily()) >+ updateHTTPRequestHeaders(request); >+ > auto& memoryCache = MemoryCache::singleton(); > if (request.allowsCaching() && memoryCache.disabled()) { > DocumentResourceMap::iterator it = m_documentResources.find(url.string()); >@@ -844,7 +891,8 @@ CachedResourceHandle<CachedResource> CachedResourceLoader::revalidateResource(Ca > CachedResourceHandle<CachedResource> CachedResourceLoader::loadResource(CachedResource::Type type, CachedResourceRequest&& request) > { > auto& memoryCache = MemoryCache::singleton(); >- ASSERT(!request.allowsCaching() || !memoryCache.resourceForRequest(request.resourceRequest(), sessionID())); >+ ASSERT(!request.allowsCaching() || !memoryCache.resourceForRequest(request.resourceRequest(), sessionID()) >+ || request.options().cache == FetchOptions::Cache::NoCache || request.options().cache == FetchOptions::Cache::NoStore || request.options().cache == FetchOptions::Cache::Reload); > > LOG(ResourceLoading, "Loading CachedResource for '%s'.", request.resourceRequest().url().stringCenterEllipsizedToLength().latin1().data()); > >@@ -897,6 +945,12 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida > if (!existingResource) > return Load; > >+ if (cachedResourceRequest.options().cache == FetchOptions::Cache::NoStore) >+ return Load; >+ >+ if (cachedResourceRequest.options().cache == FetchOptions::Cache::Reload) >+ return Reload; >+ > // We already have a preload going for this URL. > if (forPreload == ForPreload::Yes && existingResource->isPreloaded()) > return Use; >@@ -931,10 +985,12 @@ CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida > if (defer == DeferOption::DeferredByClient) > return Reload; > >- // Don't reload resources while pasting. >- if (m_allowStaleResources) >+ // Don't reload resources while pasting or if cache mode allows stale resources. >+ if (m_allowStaleResources || cachedResourceRequest.options().cache == FetchOptions::Cache::ForceCache || cachedResourceRequest.options().cache == FetchOptions::Cache::OnlyIfCached) > return Use; > >+ ASSERT(cachedResourceRequest.options().cache == FetchOptions::Cache::Default || cachedResourceRequest.options().cache == FetchOptions::Cache::NoCache); >+ > // Always use preloads. > if (existingResource->isPreloaded()) > return Use; >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h >index f8f1522d209f2953b76bddee07e09ec7b8b8c3ca..e9eed8d56afb61ff4a8372f333186fb1a59ea55a 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.h >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.h >@@ -154,6 +154,7 @@ private: > enum class ForPreload { Yes, No }; > enum class DeferOption { NoDefer, DeferredByClient }; > >+ void updateHTTPRequestHeaders(CachedResourceRequest&); > CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&&, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer); > void prepareFetch(CachedResource::Type, CachedResourceRequest&); > CachedResourceHandle<CachedResource> revalidateResource(CachedResourceRequest&&, CachedResource&); >diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.h b/Source/WebCore/loader/cache/CachedResourceRequest.h >index 28294101a42aedfe6c5fddeea12eda8a562cef07..a1377dcbde8ba2b101ea3c838242a229c3ce64dd 100644 >--- a/Source/WebCore/loader/cache/CachedResourceRequest.h >+++ b/Source/WebCore/loader/cache/CachedResourceRequest.h >@@ -60,6 +60,8 @@ public: > RefPtr<SecurityOrigin> releaseOrigin() { return WTFMove(m_origin); } > SecurityOrigin* origin() const { return m_origin.get(); } > >+ void setCacheModeToNoStore() { m_options.cache = FetchOptions::Cache::NoStore; } >+ > private: > ResourceRequest m_resourceRequest; > String m_charset; >diff --git a/Source/WebCore/page/EventSource.cpp b/Source/WebCore/page/EventSource.cpp >index 442bb9be03cfbfe98fa94758c34a236dcbc877bc..f702aa75066c415c79446e79ce90c851e5470a20 100644 >--- a/Source/WebCore/page/EventSource.cpp >+++ b/Source/WebCore/page/EventSource.cpp >@@ -108,6 +108,7 @@ void EventSource::connect() > options.credentials = m_withCredentials ? FetchOptions::Credentials::Include : FetchOptions::Credentials::SameOrigin; > options.preflightPolicy = PreventPreflight; > options.mode = FetchOptions::Mode::Cors; >+ options.cache = FetchOptions::Cache::NoStore; > options.dataBufferingPolicy = DoNotBufferData; > options.contentSecurityPolicyEnforcement = scriptExecutionContext()->shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective; > >diff --git a/Source/WebCore/platform/network/HTTPHeaderMap.cpp b/Source/WebCore/platform/network/HTTPHeaderMap.cpp >index bb20f7080ff24dd0e0d7f3ca15545c23c1c427b9..4fc814849c886a34bdbf0d32211faf8b0538b65c 100644 >--- a/Source/WebCore/platform/network/HTTPHeaderMap.cpp >+++ b/Source/WebCore/platform/network/HTTPHeaderMap.cpp >@@ -103,6 +103,11 @@ void HTTPHeaderMap::add(const String& name, const String& value) > add(headerName, value); > } > >+bool HTTPHeaderMap::addIfNotPresent(HTTPHeaderName headerName, const String& value) >+{ >+ return m_commonHeaders.add(headerName, value).isNewEntry; >+} >+ > bool HTTPHeaderMap::contains(const String& name) const > { > HTTPHeaderName headerName; >diff --git a/Source/WebCore/platform/network/HTTPHeaderMap.h b/Source/WebCore/platform/network/HTTPHeaderMap.h >index 3709f2573f207d0b797eee9e63b67f08a3f5dc26..1495a6c924eb31e04ddfdc5eceddbcd5c996830d 100644 >--- a/Source/WebCore/platform/network/HTTPHeaderMap.h >+++ b/Source/WebCore/platform/network/HTTPHeaderMap.h >@@ -141,6 +141,7 @@ public: > WEBCORE_EXPORT String get(HTTPHeaderName) const; > void set(HTTPHeaderName, const String& value); > void add(HTTPHeaderName, const String& value); >+ bool addIfNotPresent(HTTPHeaderName, const String&); > bool contains(HTTPHeaderName) const; > WEBCORE_EXPORT bool remove(HTTPHeaderName); > >diff --git a/Source/WebCore/platform/network/HTTPHeaderValues.cpp b/Source/WebCore/platform/network/HTTPHeaderValues.cpp >index 4642d05bbe2c9dac94ed6102bc6f14ef6509a33a..72df220a003d4fb0a723fd9b19e4663e61f0bb00 100644 >--- a/Source/WebCore/platform/network/HTTPHeaderValues.cpp >+++ b/Source/WebCore/platform/network/HTTPHeaderValues.cpp >@@ -44,6 +44,18 @@ const String& formURLEncodedContentType() > return contentType; > } > >+const String& noCache() >+{ >+ static NeverDestroyed<const String> value(ASCIILiteral("no-cache")); >+ return value; >+} >+ >+const String& maxAge0() >+{ >+ static NeverDestroyed<const String> value(ASCIILiteral("max-age=0")); >+ return value; >+} >+ > } > > } >diff --git a/Source/WebCore/platform/network/HTTPHeaderValues.h b/Source/WebCore/platform/network/HTTPHeaderValues.h >index 299b5a7f1754bea7484414caada729d00a617f43..9d85f961ba4e8429f847460fa041a51078f4eea9 100644 >--- a/Source/WebCore/platform/network/HTTPHeaderValues.h >+++ b/Source/WebCore/platform/network/HTTPHeaderValues.h >@@ -32,7 +32,8 @@ namespace HTTPHeaderValues { > > const String& textPlainContentType(); > const String& formURLEncodedContentType(); >- >+const String& noCache(); >+const String& maxAge0(); > } > > } >diff --git a/Source/WebCore/platform/network/ResourceRequestBase.cpp b/Source/WebCore/platform/network/ResourceRequestBase.cpp >index a6b5356dea4242d93e95b1d3c4d0e9e0798bc6d5..f223bfe0b4bb76ceba262bca2815bd1e0b31f7c8 100644 >--- a/Source/WebCore/platform/network/ResourceRequestBase.cpp >+++ b/Source/WebCore/platform/network/ResourceRequestBase.cpp >@@ -464,6 +464,17 @@ void ResourceRequestBase::setPriority(ResourceLoadPriority priority) > m_platformRequestUpdated = false; > } > >+void ResourceRequestBase::addHTTPHeaderFieldIfNotPresent(HTTPHeaderName name, const String& value) >+{ >+ updateResourceRequest(); >+ >+ if (!m_httpHeaderFields.addIfNotPresent(name, value)) >+ return; >+ >+ if (url().protocolIsInHTTPFamily()) >+ m_platformRequestUpdated = false; >+} >+ > void ResourceRequestBase::addHTTPHeaderField(HTTPHeaderName name, const String& value) > { > updateResourceRequest(); >@@ -477,13 +488,18 @@ void ResourceRequestBase::addHTTPHeaderField(HTTPHeaderName name, const String& > void ResourceRequestBase::addHTTPHeaderField(const String& name, const String& value) > { > updateResourceRequest(); >- >+ > m_httpHeaderFields.add(name, value); >- >+ > if (url().protocolIsInHTTPFamily()) > m_platformRequestUpdated = false; > } >- >+ >+bool ResourceRequestBase::hasHTTPHeaderField(HTTPHeaderName headerName) const >+{ >+ return m_httpHeaderFields.contains(headerName); >+} >+ > void ResourceRequestBase::setHTTPHeaderFields(HTTPHeaderMap headerFields) > { > updateResourceRequest(); >diff --git a/Source/WebCore/platform/network/ResourceRequestBase.h b/Source/WebCore/platform/network/ResourceRequestBase.h >index 010acc53fc3cecae7493a17668611e0dcac9bfe7..49fb67f745262c9c49bcd0387972f99895dbce8b 100644 >--- a/Source/WebCore/platform/network/ResourceRequestBase.h >+++ b/Source/WebCore/platform/network/ResourceRequestBase.h >@@ -85,6 +85,9 @@ public: > WEBCORE_EXPORT void setHTTPHeaderField(HTTPHeaderName, const String& value); > void addHTTPHeaderField(HTTPHeaderName, const String& value); > void addHTTPHeaderField(const String& name, const String& value); >+ void addHTTPHeaderFieldIfNotPresent(HTTPHeaderName, const String&); >+ >+ bool hasHTTPHeaderField(HTTPHeaderName) const; > > // Instead of passing a string literal to any of these functions, just use a HTTPHeaderName instead. > template<size_t length> String httpHeaderField(const char (&)[length]) const = delete; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 57123aa5495df1aac10ade26d677c191f1656ab2..8cf6d1125503b587c6b662289628a98af63c0d05 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2016-10-11 Youenn Fablet <youenn@apple.com> >+ >+ [Fetch API] Support Request cache mode >+ https://bugs.webkit.org/show_bug.cgi?id=162281 >+ >+ Reviewed by Alex Christensen. >+ >+ Activating request-cache.html tests for WK1, but not yet for WK2. >+ >+ * TestExpectations: >+ * platform/mac/TestExpectations: >+ * platform/wk2/TestExpectations: >+ > 2016-10-11 Chris Dumez <cdumez@apple.com> > > Update IDBVersionChangeEvent to stop using legacy [ConstructorTemplate=Event] >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 4be11b9ea7f91574a0a45dc9e40ca792e259888b..8b5a953b4d4862a0747c9a152f6bb50199f8f85d 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,14 @@ >+2016-10-11 Youenn Fablet <youenn@apple.com> >+ >+ [Fetch API] Support Request cache mode >+ https://bugs.webkit.org/show_bug.cgi?id=162281 >+ >+ Reviewed by Alex Christensen. >+ >+ * web-platform-tests/fetch/api/request/request-cache-expected.txt: Rebasing test now that more tests are passing. >+ * web-platform-tests/fetch/api/request/request-error-expected.txt: >+ * web-platform-tests/fetch/api/request/request-error.html: Adding test to ensure only-if-cached is used with same-origin fetch mode. >+ > 2016-10-10 Chris Dumez <cdumez@apple.com> > > Add support for languagechange event >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 5cb82a17b72a0fc79e302b702e5a5f6ff60baffb..0888272f30a526b5865f5db900005a5a81b6239c 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -282,8 +282,6 @@ imported/w3c/web-platform-tests/XMLHttpRequest/send-redirect-to-non-cors.htm [ S > # Failing assertion with dynamic message > imported/w3c/web-platform-tests/XMLHttpRequest/responsexml-document-properties.htm [ Failure ] > >-imported/w3c/web-platform-tests/fetch/api/request/request-cache.html [ Skip ] >- > webkit.org/b/161176 [ Debug ] imported/w3c/web-platform-tests/url/url-setters.html [ Skip ] > > webkit.org/b/157068 imported/w3c/web-platform-tests/fetch/nosniff/importscripts.html [ Skip ] >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-expected.txt >index ec1501adc2ea7a97f27dc062327bf39c0b54d13a..5529cb0e0e27b55b53e255fa49204532fdd1861d 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-expected.txt >@@ -5,10 +5,10 @@ PASS RequestCache "default" mode checks the cache for previously cached content > PASS RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with date and fresh response > PASS RequestCache "no-cache" mode revalidates stale responses found in the cache with Etag and stale response > PASS RequestCache "no-cache" mode revalidates stale responses found in the cache with date and stale response >-FAIL RequestCache "no-cache" mode revalidates fresh responses found in the cache with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "no-cache" mode revalidates fresh responses found in the cache with date and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Etag and stale response assert_equals: expected 1 but got 2 >-FAIL RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with date and stale response assert_equals: expected 1 but got 2 >+PASS RequestCache "no-cache" mode revalidates fresh responses found in the cache with Etag and fresh response >+PASS RequestCache "no-cache" mode revalidates fresh responses found in the cache with date and fresh response >+PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Etag and stale response >+PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with date and stale response > PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Etag and fresh response > PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with date and fresh response > PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found with Etag and stale response >@@ -23,10 +23,10 @@ PASS RequestCache "force-cache" stores the response in the cache if it goes to t > PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with date and stale response > PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and fresh response > PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with date and fresh response >-FAIL RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response promise_test: Unhandled rejection with value: object "TypeError: Type error" >-FAIL RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with date and stale response promise_test: Unhandled rejection with value: object "TypeError: Type error" >-FAIL RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response promise_test: Unhandled rejection with value: object "TypeError: Type error" >-FAIL RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with date and fresh response promise_test: Unhandled rejection with value: object "TypeError: Type error" >+PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response >+PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with date and stale response >+PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response >+PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with date and fresh response > PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with Etag and fresh response > PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and does not go to the network if a cached response is not found with date and fresh response > FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and fresh response promise_test: Unhandled rejection with value: object "TypeError: Type error" >@@ -37,21 +37,21 @@ PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirect > PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and fresh response > PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and stale response > PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and stale response >-FAIL RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response assert_equals: expected (undefined) undefined but got (string) "\"0.04196530864700354\"" >-FAIL RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response assert_equals: expected (undefined) undefined but got (string) "Fri, 09 Sep 2016 08:49:10 GMT" >-FAIL RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "no-store" mode does not store the response in the cache with Etag and stale response assert_equals: expected (undefined) undefined but got (string) "\"0.12846053184726147\"" >-FAIL RequestCache "no-store" mode does not store the response in the cache with date and stale response assert_equals: expected (undefined) undefined but got (string) "Fri, 09 Sep 2016 08:49:10 GMT" >-FAIL RequestCache "no-store" mode does not store the response in the cache with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "no-store" mode does not store the response in the cache with date and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response >+PASS RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response >+PASS RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response >+PASS RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response >+PASS RequestCache "no-store" mode does not store the response in the cache with Etag and stale response >+PASS RequestCache "no-store" mode does not store the response in the cache with date and stale response >+PASS RequestCache "no-store" mode does not store the response in the cache with Etag and fresh response >+PASS RequestCache "no-store" mode does not store the response in the cache with date and fresh response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and stale response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and stale response >-FAIL RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response > PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and stale response >@@ -59,46 +59,46 @@ PASS RequestCache "default" mode with an If-None-Match header is treated similar > PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and stale response >-FAIL RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response >+PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and stale response > PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response > PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and stale response >-FAIL RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response >+PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and stale response > PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response > PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and stale response >-FAIL RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response >+PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and stale response > PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response > PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response > PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response > PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and stale response >-FAIL RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response >+PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response > PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and stale response > PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with date and stale response > PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and fresh response > PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with date and fresh response >-FAIL RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response assert_equals: expected (undefined) undefined but got (string) "\"0.7894894845056666\"" >-FAIL RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response assert_equals: expected (undefined) undefined but got (string) "Fri, 09 Sep 2016 08:49:10 GMT" >-FAIL RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response assert_equals: expected 2 but got 1 >+PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response >+PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response >+PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response >+PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response > PASS RequestCache "reload" mode does store the response in the cache with Etag and stale response > PASS RequestCache "reload" mode does store the response in the cache with date and stale response >-PASS RequestCache "reload" mode does store the response in the cache with Etag and fresh response >-PASS RequestCache "reload" mode does store the response in the cache with date and fresh response >-FAIL RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and stale response assert_equals: expected (undefined) undefined but got (string) "\"0.49509960167414313\"" >-FAIL RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and stale response assert_equals: expected (undefined) undefined but got (string) "Fri, 09 Sep 2016 08:49:10 GMT" >-FAIL RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response assert_equals: expected 2 but got 1 >-FAIL RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and fresh response assert_equals: expected 2 but got 1 >+FAIL RequestCache "reload" mode does store the response in the cache with Etag and fresh response assert_equals: expected 1 but got 2 >+FAIL RequestCache "reload" mode does store the response in the cache with date and fresh response assert_equals: expected 1 but got 2 >+PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and stale response >+PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and stale response >+PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response >+PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and fresh response > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error-expected.txt >index a9e8e372de6e61f8a5615cde906884d17d455cd2..e80fba8724db8aa30b3d9ae88fbd5623f3cfa9d1 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error-expected.txt >@@ -19,4 +19,8 @@ PASS Bad mode init parameter value > PASS Bad credentials init parameter value > PASS Bad cache init parameter value > PASS Bad redirect init parameter value >+PASS Request with cache mode: only-if-cached and fetch mode: same-origin >+PASS Request with cache mode: only-if-cached and fetch mode: cors >+PASS Request with cache mode: only-if-cached and fetch mode: no-cors >+PASS Request should not get its content-type from the init request if init headers are provided > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error.html b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error.html >index c87429e76372608a7ba8763c255a6a30e04e2ae8..279aeda573e3c6f8d4de4c790eb6e883b8368b68 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error.html >+++ b/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-error.html >@@ -105,6 +105,28 @@ > assert_throws(new TypeError(), function() { new Request("", options); }); > },"Bad " + parameter +" init parameter value"); > }); >+ >+ function testOnlyIfCachedMode(fetchMode, ok) { >+ test(function() { >+ var options = {"cache": "only-if-cached", "mode": fetchMode}; >+ if (ok) >+ new Request("test", options); >+ else >+ assert_throws(new TypeError(), function() { new Request("test", options); }); >+ }, "Request with cache mode: only-if-cached and fetch mode: " + fetchMode); >+ } >+ testOnlyIfCachedMode("same-origin", true); >+ testOnlyIfCachedMode("cors", false); >+ testOnlyIfCachedMode("no-cors", false); >+ >+ test(function() { >+ var initialHeaders = new Headers([["Content-Type", "potato"]]); >+ var initialRequest = new Request("", {"headers" : initialHeaders}); >+ var headers = new Headers([]); >+ var request = new Request(initialRequest, {"headers" : headers}); >+ assert_false(request.headers.has("Content-Type")); >+ }, "Request should not get its content-type from the init request if init headers are provided"); >+ > </script> > </body> > </html> >diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations >index 8102e6c68d7f433757ad6c6159032d32b71c1fa9..ecb0df69d38a8bdb98555fd6615c2162a2a67465 100644 >--- a/LayoutTests/platform/mac/TestExpectations >+++ b/LayoutTests/platform/mac/TestExpectations >@@ -1403,8 +1403,6 @@ webkit.org/b/158747 media/restore-from-page-cache.html [ Pass Failure ] > # See also https://bugs.webkit.org/show_bug.cgi?id=162494 > webkit.org/b/151287 [ ElCapitan+ ] media/controls/inline-elements-dropoff-order.html [ Failure ] > >-webkit.org/b/159683 imported/w3c/web-platform-tests/fetch/api/request/request-cache.html [ Pass Failure ] >- > webkit.org/b/158500 storage/indexeddb/database-close-private.html [ Pass Failure ] > > webkit.org/b/163122 imported/blink/storage/indexeddb/blob-valid-after-deletion.html [ Pass Timeout ] >diff --git a/LayoutTests/platform/wk2/TestExpectations b/LayoutTests/platform/wk2/TestExpectations >index 9c29d4d61584590d14a3c860c0509e98b3181d1b..17569dd5028d43eb3b1d9f086d119a54e22600c5 100644 >--- a/LayoutTests/platform/wk2/TestExpectations >+++ b/LayoutTests/platform/wk2/TestExpectations >@@ -684,6 +684,9 @@ fast/images/gif-loop-count.html [ Pass ] > # DumpRenderTree does not implement setWillSendRequestHTTPBody > http/tests/misc/will-send-request-with-client-provided-http-body.html [ Pass ] > >+# bug 162281 >+imported/w3c/web-platform-tests/fetch/api/request/request-cache.html [ Skip ] >+ > ### END OF (5) Progressions, expected successes that are expected failures in WebKit1. > ######################################## >
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 162281
:
289358
|
289373
|
289374
|
289376
|
289378
|
289448
|
289456
| 291246