<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194880] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194880">194880</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2016-01-11 18:12:37 -0800 (Mon, 11 Jan 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Cocoa] Add SPI to opt out a URL scheme from the memory cache
https://bugs.webkit.org/show_bug.cgi?id=152950
rdar://problem/24066652
Reviewed by Tim Horton.
Source/WebCore:
Added a list of schemes to SchemeRegistry whose resources should always be revalidated. Taught CachedResource to
return a freshness lifetime of 0 for these resources, unless the scheme is one that should be cached indefinitely.
New API test: WebKit2.AlwaysRevalidatedURLSchemes
* loader/cache/CachedResource.cpp:
(WebCore::shouldCacheSchemeIndefinitely): Moved from SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely().
(WebCore::CachedResource::freshnessLifetime): For a scheme that should not be cached indefinitely, return 0 if
that scheme should always be revalidated according to SchemeRegistry.
* platform/SchemeRegistry.cpp:
(WebCore::alwaysRevalidatedSchemes):
(WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated):
(WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme):
(WebCore::SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely): Moved to WebCore::shouldCacheSchemeIndefinitely().
There was no reason for this to be in SchemeRegistry.
* platform/SchemeRegistry.h:
Source/WebKit2:
Added a alwaysRevalidatedURLSchemes property to _WKProcessPoolConfiguration. Taught WebProcess to add these
schemes to SchemeRegistry when initializing a new web process.
* Shared/API/Cocoa/WKFoundation.h: Added a newline to force re-postprocessing.
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration alwaysRevalidatedURLSchemes]):
(-[_WKProcessPoolConfiguration setAlwaysRevalidatedURLSchemes:]):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::createNewWebProcess):
* UIProcess/WebProcessPool.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::registerURLSchemeAsAlwaysRevalidated):
* WebProcess/WebProcess.h:
Tools:
Added an API test.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm: Added.
(+[AlwaysRevalidatedURLSchemeProtocol canInitWithRequest:]):
(+[AlwaysRevalidatedURLSchemeProtocol canonicalRequestForRequest:]):
(+[AlwaysRevalidatedURLSchemeProtocol requestIsCacheEquivalent:toRequest:]):
(-[AlwaysRevalidatedURLSchemeProtocol startLoading]):
(-[AlwaysRevalidatedURLSchemeProtocol stopLoading]):
(-[AlwaysRevalidatedURLSchemesDelegate webView:didFinishNavigation:]):
(TEST):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourcecpp">trunk/Source/WebCore/loader/cache/CachedResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformSchemeRegistrycpp">trunk/Source/WebCore/platform/SchemeRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformSchemeRegistryh">trunk/Source/WebCore/platform/SchemeRegistry.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedAPICocoaWKFoundationh">trunk/Source/WebKit2/Shared/API/Cocoa/WKFoundation.h</a></li>
<li><a href="#trunkSourceWebKit2SharedWebProcessCreationParameterscpp">trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedWebProcessCreationParametersh">trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationcpp">trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationh">trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKProcessPoolConfigurationh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKProcessPoolConfigurationmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolcpp">trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebProcessPoolh">trunk/Source/WebKit2/UIProcess/WebProcessPool.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcesscpp">trunk/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebProcessh">trunk/Source/WebKit2/WebProcess/WebProcess.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaAlwaysRevalidatedURLSchemesmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebCore/ChangeLog        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-01-09 Andy Estes <aestes@apple.com>
+
+ [Cocoa] Add SPI to opt out a URL scheme from the memory cache
+ https://bugs.webkit.org/show_bug.cgi?id=152950
+ rdar://problem/24066652
+
+ Reviewed by Tim Horton.
+
+ Added a list of schemes to SchemeRegistry whose resources should always be revalidated. Taught CachedResource to
+ return a freshness lifetime of 0 for these resources, unless the scheme is one that should be cached indefinitely.
+
+ New API test: WebKit2.AlwaysRevalidatedURLSchemes
+
+ * loader/cache/CachedResource.cpp:
+ (WebCore::shouldCacheSchemeIndefinitely): Moved from SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely().
+ (WebCore::CachedResource::freshnessLifetime): For a scheme that should not be cached indefinitely, return 0 if
+ that scheme should always be revalidated according to SchemeRegistry.
+ * platform/SchemeRegistry.cpp:
+ (WebCore::alwaysRevalidatedSchemes):
+ (WebCore::SchemeRegistry::registerURLSchemeAsAlwaysRevalidated):
+ (WebCore::SchemeRegistry::shouldAlwaysRevalidateURLScheme):
+ (WebCore::SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely): Moved to WebCore::shouldCacheSchemeIndefinitely().
+ There was no reason for this to be in SchemeRegistry.
+ * platform/SchemeRegistry.h:
+
</ins><span class="cx"> 2016-01-11 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> Modern IDB: storage/indexeddb/index-multientry.html fails under GuardMalloc/ASAN.
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.cpp        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -359,14 +359,26 @@
</span><span class="cx"> return computeCurrentAge(m_response, m_responseTimestamp) > freshnessLifetime(m_response);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static inline bool shouldCacheSchemeIndefinitely(const String& scheme)
+{
+#if PLATFORM(COCOA)
+ if (equalIgnoringCase(scheme, "applewebdata"))
+ return true;
+#endif
+ return equalIgnoringCase(scheme, "data");
+}
+
</ins><span class="cx"> std::chrono::microseconds CachedResource::freshnessLifetime(const ResourceResponse& response) const
</span><span class="cx"> {
</span><span class="cx"> if (!response.url().protocolIsInHTTPFamily()) {
</span><del>- // Don't cache non-HTTP main resources since we can't check for freshness.
- // FIXME: We should not cache subresources either, but when we tried this
- // it caused performance and flakiness issues in our test infrastructure.
- if (m_type == MainResource && !SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely(response.url().protocol()))
- return std::chrono::microseconds::zero();
</del><ins>+ String protocol = response.url().protocol();
+ if (!shouldCacheSchemeIndefinitely(protocol)) {
+ // Don't cache non-HTTP main resources since we can't check for freshness.
+ // FIXME: We should not cache subresources either, but when we tried this
+ // it caused performance and flakiness issues in our test infrastructure.
+ if (m_type == MainResource || SchemeRegistry::shouldAlwaysRevalidateURLScheme(protocol))
+ return std::chrono::microseconds::zero();
+ }
</ins><span class="cx">
</span><span class="cx"> return std::chrono::microseconds::max();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSchemeRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/SchemeRegistry.cpp (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SchemeRegistry.cpp        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebCore/platform/SchemeRegistry.cpp        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -179,6 +179,12 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+static URLSchemesMap& alwaysRevalidatedSchemes()
+{
+ static NeverDestroyed<URLSchemesMap> schemes;
+ return schemes;
+}
+
</ins><span class="cx"> bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
</span><span class="cx"> {
</span><span class="cx"> if (scheme.isEmpty())
</span><span class="lines">@@ -329,15 +335,18 @@
</span><span class="cx"> return ContentSecurityPolicyBypassingSchemes().contains(scheme);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool SchemeRegistry::shouldCacheResponsesFromURLSchemeIndefinitely(const String& scheme)
</del><ins>+void SchemeRegistry::registerURLSchemeAsAlwaysRevalidated(const String& scheme)
</ins><span class="cx"> {
</span><del>-#if PLATFORM(COCOA)
- if (equalIgnoringCase(scheme, "applewebdata"))
- return true;
-#endif
- return equalIgnoringCase(scheme, "data");
</del><ins>+ alwaysRevalidatedSchemes().add(scheme);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+bool SchemeRegistry::shouldAlwaysRevalidateURLScheme(const String& scheme)
+{
+ if (scheme.isEmpty())
+ return false;
+ return alwaysRevalidatedSchemes().contains(scheme);
+}
+
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> void SchemeRegistry::registerURLSchemeAsCachePartitioned(const String& scheme)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformSchemeRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/SchemeRegistry.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/SchemeRegistry.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebCore/platform/SchemeRegistry.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -88,10 +88,11 @@
</span><span class="cx"> WEBCORE_EXPORT static void registerURLSchemeAsBypassingContentSecurityPolicy(const String& scheme);
</span><span class="cx"> WEBCORE_EXPORT static void removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(const String& scheme);
</span><span class="cx"> static bool schemeShouldBypassContentSecurityPolicy(const String& scheme);
</span><del>-
- // Schemes whose responses can be cached indefinitely.
- static bool shouldCacheResponsesFromURLSchemeIndefinitely(const String& scheme);
</del><span class="cx">
</span><ins>+ // Schemes whose responses should always be revalidated.
+ WEBCORE_EXPORT static void registerURLSchemeAsAlwaysRevalidated(const String&);
+ static bool shouldAlwaysRevalidateURLScheme(const String&);
+
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> // Schemes whose requests should be partitioned in the cache
</span><span class="cx"> WEBCORE_EXPORT static void registerURLSchemeAsCachePartitioned(const String& scheme);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/ChangeLog        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-01-09 Andy Estes <aestes@apple.com>
+
+ [Cocoa] Add SPI to opt out a URL scheme from the memory cache
+ https://bugs.webkit.org/show_bug.cgi?id=152950
+ rdar://problem/24066652
+
+ Reviewed by Tim Horton.
+
+ Added a alwaysRevalidatedURLSchemes property to _WKProcessPoolConfiguration. Taught WebProcess to add these
+ schemes to SchemeRegistry when initializing a new web process.
+
+ * Shared/API/Cocoa/WKFoundation.h: Added a newline to force re-postprocessing.
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::encode):
+ (WebKit::WebProcessCreationParameters::decode):
+ * Shared/WebProcessCreationParameters.h:
+ * UIProcess/API/APIProcessPoolConfiguration.cpp:
+ (API::ProcessPoolConfiguration::copy):
+ * UIProcess/API/APIProcessPoolConfiguration.h:
+ * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+ * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+ (-[_WKProcessPoolConfiguration alwaysRevalidatedURLSchemes]):
+ (-[_WKProcessPoolConfiguration setAlwaysRevalidatedURLSchemes:]):
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::createNewWebProcess):
+ * UIProcess/WebProcessPool.h:
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::initializeWebProcess):
+ (WebKit::WebProcess::registerURLSchemeAsAlwaysRevalidated):
+ * WebProcess/WebProcess.h:
+
</ins><span class="cx"> 2016-01-11 Anders Carlsson <andersca@apple.com>
</span><span class="cx">
</span><span class="cx"> Get rid of CFMakeCollectable, it is a no-op
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPICocoaWKFoundationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKFoundation.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/Cocoa/WKFoundation.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKFoundation.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -116,3 +116,4 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #endif
</span><ins>+
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedWebProcessCreationParameterscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx"> encoder << urlSchemesRegisteredAsNoAccess;
</span><span class="cx"> encoder << urlSchemesRegisteredAsDisplayIsolated;
</span><span class="cx"> encoder << urlSchemesRegisteredAsCORSEnabled;
</span><ins>+ encoder << urlSchemesRegisteredAsAlwaysRevalidated;
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> encoder << urlSchemesRegisteredAsCachePartitioned;
</span><span class="cx"> #endif
</span><span class="lines">@@ -202,6 +203,8 @@
</span><span class="cx"> return false;
</span><span class="cx"> if (!decoder.decode(parameters.urlSchemesRegisteredAsCORSEnabled))
</span><span class="cx"> return false;
</span><ins>+ if (!decoder.decode(parameters.urlSchemesRegisteredAsAlwaysRevalidated))
+ return false;
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> if (!decoder.decode(parameters.urlSchemesRegisteredAsCachePartitioned))
</span><span class="cx"> return false;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebProcessCreationParametersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -96,6 +96,7 @@
</span><span class="cx"> Vector<String> urlSchemesRegisteredAsNoAccess;
</span><span class="cx"> Vector<String> urlSchemesRegisteredAsDisplayIsolated;
</span><span class="cx"> Vector<String> urlSchemesRegisteredAsCORSEnabled;
</span><ins>+ Vector<String> urlSchemesRegisteredAsAlwaysRevalidated;
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> Vector<String> urlSchemesRegisteredAsCachePartitioned;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.cpp        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> copy->m_mediaKeysStorageDirectory = this->m_mediaKeysStorageDirectory;
</span><span class="cx"> copy->m_webSQLDatabaseDirectory = this->m_webSQLDatabaseDirectory;
</span><span class="cx"> copy->m_cachePartitionedURLSchemes = this->m_cachePartitionedURLSchemes;
</span><ins>+ copy->m_alwaysRevalidatedURLSchemes = this->m_alwaysRevalidatedURLSchemes;
</ins><span class="cx"> copy->m_fullySynchronousModeIsAllowedForTesting = this->m_fullySynchronousModeIsAllowedForTesting;
</span><span class="cx"> copy->m_overrideLanguages = this->m_overrideLanguages;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIProcessPoolConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/UIProcess/API/APIProcessPoolConfiguration.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -80,6 +80,9 @@
</span><span class="cx"> const Vector<WTF::String>& cachePartitionedURLSchemes() { return m_cachePartitionedURLSchemes; }
</span><span class="cx"> void setCachePartitionedURLSchemes(Vector<WTF::String>&& cachePartitionedURLSchemes) { m_cachePartitionedURLSchemes = WTFMove(cachePartitionedURLSchemes); }
</span><span class="cx">
</span><ins>+ const Vector<WTF::String>& alwaysRevalidatedURLSchemes() { return m_alwaysRevalidatedURLSchemes; }
+ void setAlwaysRevalidatedURLSchemes(Vector<WTF::String>&& alwaysRevalidatedURLSchemes) { m_alwaysRevalidatedURLSchemes = WTFMove(alwaysRevalidatedURLSchemes); }
+
</ins><span class="cx"> bool fullySynchronousModeIsAllowedForTesting() const { return m_fullySynchronousModeIsAllowedForTesting; }
</span><span class="cx"> void setFullySynchronousModeIsAllowedForTesting(bool allowed) { m_fullySynchronousModeIsAllowedForTesting = allowed; }
</span><span class="cx">
</span><span class="lines">@@ -101,6 +104,7 @@
</span><span class="cx"> WTF::String m_webSQLDatabaseDirectory;
</span><span class="cx"> WTF::String m_mediaKeysStorageDirectory;
</span><span class="cx"> Vector<WTF::String> m_cachePartitionedURLSchemes;
</span><ins>+ Vector<WTF::String> m_alwaysRevalidatedURLSchemes;
</ins><span class="cx"> bool m_fullySynchronousModeIsAllowedForTesting { false };
</span><span class="cx"> Vector<WTF::String> m_overrideLanguages;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKProcessPoolConfigurationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> @property (nonatomic) NSUInteger maximumProcessCount;
</span><span class="cx"> @property (nonatomic) NSInteger diskCacheSizeOverride WK_AVAILABLE(10_11, 9_0);
</span><span class="cx"> @property (nonatomic, copy) NSArray *cachePartitionedURLSchemes;
</span><ins>+@property (nonatomic, copy) WK_ARRAY(NSString *) *alwaysRevalidatedURLSchemes WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKProcessPoolConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -106,6 +106,31 @@
</span><span class="cx"> _processPoolConfiguration->setCachePartitionedURLSchemes(WTFMove(schemes));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (NSArray *)alwaysRevalidatedURLSchemes
+{
+ auto& schemes = _processPoolConfiguration->alwaysRevalidatedURLSchemes();
+ if (schemes.isEmpty())
+ return @[];
+
+ NSMutableArray *array = [NSMutableArray arrayWithCapacity:schemes.size()];
+ for (auto& scheme : schemes)
+ [array addObject:(NSString *)scheme];
+
+ return array;
+}
+
+- (void)setAlwaysRevalidatedURLSchemes:(NSArray *)alwaysRevalidatedURLSchemes
+{
+ Vector<String> schemes;
+ schemes.reserveInitialCapacity(alwaysRevalidatedURLSchemes.count);
+ for (id scheme in alwaysRevalidatedURLSchemes) {
+ if ([scheme isKindOfClass:[NSString class]])
+ schemes.append((NSString *)scheme);
+ }
+
+ _processPoolConfiguration->setAlwaysRevalidatedURLSchemes(WTFMove(schemes));
+}
+
</ins><span class="cx"> - (NSString *)description
</span><span class="cx"> {
</span><span class="cx"> NSString *description = [NSString stringWithFormat:@"<%@: %p; maximumProcessCount = %lu", NSStringFromClass(self.class), self, static_cast<unsigned long>([self maximumProcessCount])];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -161,6 +161,9 @@
</span><span class="cx"> , m_userObservablePageCounter([this](bool) { updateProcessSuppressionState(); })
</span><span class="cx"> , m_processSuppressionDisabledForPageCounter([this](bool) { updateProcessSuppressionState(); })
</span><span class="cx"> {
</span><ins>+ for (auto& scheme : m_configuration->alwaysRevalidatedURLSchemes())
+ m_schemesToRegisterAsAlwaysRevalidated.add(scheme);
+
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> for (const auto& urlScheme : m_configuration->cachePartitionedURLSchemes())
</span><span class="cx"> m_schemesToRegisterAsCachePartitioned.add(urlScheme);
</span><span class="lines">@@ -571,6 +574,7 @@
</span><span class="cx"> copyToVector(m_schemesToRegisterAsNoAccess, parameters.urlSchemesRegisteredAsNoAccess);
</span><span class="cx"> copyToVector(m_schemesToRegisterAsDisplayIsolated, parameters.urlSchemesRegisteredAsDisplayIsolated);
</span><span class="cx"> copyToVector(m_schemesToRegisterAsCORSEnabled, parameters.urlSchemesRegisteredAsCORSEnabled);
</span><ins>+ copyToVector(m_schemesToRegisterAsAlwaysRevalidated, parameters.urlSchemesRegisteredAsAlwaysRevalidated);
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> copyToVector(m_schemesToRegisterAsCachePartitioned, parameters.urlSchemesRegisteredAsCachePartitioned);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebProcessPoolh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebProcessPool.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebProcessPool.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/UIProcess/WebProcessPool.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -440,6 +440,7 @@
</span><span class="cx"> HashSet<String> m_schemesToRegisterAsNoAccess;
</span><span class="cx"> HashSet<String> m_schemesToRegisterAsDisplayIsolated;
</span><span class="cx"> HashSet<String> m_schemesToRegisterAsCORSEnabled;
</span><ins>+ HashSet<String> m_schemesToRegisterAsAlwaysRevalidated;
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> HashSet<String> m_schemesToRegisterAsCachePartitioned;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -305,6 +305,9 @@
</span><span class="cx"> for (auto& scheme : parameters.urlSchemesRegisteredAsCORSEnabled)
</span><span class="cx"> registerURLSchemeAsCORSEnabled(scheme);
</span><span class="cx">
</span><ins>+ for (auto& scheme : parameters.urlSchemesRegisteredAsAlwaysRevalidated)
+ registerURLSchemeAsAlwaysRevalidated(scheme);
+
</ins><span class="cx"> WebCore::Settings::setShouldRewriteConstAsVar(parameters.shouldRewriteConstAsVar);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="lines">@@ -425,6 +428,11 @@
</span><span class="cx"> SchemeRegistry::registerURLSchemeAsCORSEnabled(urlScheme);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebProcess::registerURLSchemeAsAlwaysRevalidated(const String& urlScheme) const
+{
+ SchemeRegistry::registerURLSchemeAsAlwaysRevalidated(urlScheme);
+}
+
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> void WebProcess::registerURLSchemeAsCachePartitioned(const String& urlScheme) const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebProcess.h        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -219,6 +219,7 @@
</span><span class="cx"> void registerURLSchemeAsNoAccess(const String&) const;
</span><span class="cx"> void registerURLSchemeAsDisplayIsolated(const String&) const;
</span><span class="cx"> void registerURLSchemeAsCORSEnabled(const String&) const;
</span><ins>+ void registerURLSchemeAsAlwaysRevalidated(const String&) const;
</ins><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx"> void registerURLSchemeAsCachePartitioned(const String&) const;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Tools/ChangeLog        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-01-09 Andy Estes <aestes@apple.com>
+
+ [Cocoa] Add SPI to opt out a URL scheme from the memory cache
+ https://bugs.webkit.org/show_bug.cgi?id=152950
+ rdar://problem/24066652
+
+ Reviewed by Tim Horton.
+
+ Added an API test.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm: Added.
+ (+[AlwaysRevalidatedURLSchemeProtocol canInitWithRequest:]):
+ (+[AlwaysRevalidatedURLSchemeProtocol canonicalRequestForRequest:]):
+ (+[AlwaysRevalidatedURLSchemeProtocol requestIsCacheEquivalent:toRequest:]):
+ (-[AlwaysRevalidatedURLSchemeProtocol startLoading]):
+ (-[AlwaysRevalidatedURLSchemeProtocol stopLoading]):
+ (-[AlwaysRevalidatedURLSchemesDelegate webView:didFinishNavigation:]):
+ (TEST):
+
</ins><span class="cx"> 2016-01-11 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r194866.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (194879 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-01-12 01:40:24 UTC (rev 194879)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -280,6 +280,7 @@
</span><span class="cx">                 A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC58E1B8AE36500D107EB /* TestProtocol.mm */; };
</span><span class="cx">                 A1C4FB6E1BACCE50003742D0 /* QuickLook.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */; };
</span><span class="cx">                 A1C4FB731BACD1CA003742D0 /* pages.pages in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1C4FB721BACD1B7003742D0 /* pages.pages */; };
</span><ins>+                A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */; };
</ins><span class="cx">                 A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
</span><span class="cx">                 A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
</span><span class="cx">                 B55AD1D5179F3B3000AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */; };
</span><span class="lines">@@ -673,6 +674,7 @@
</span><span class="cx">                 A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; };
</span><span class="cx">                 A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLook.mm; sourceTree = "<group>"; };
</span><span class="cx">                 A1C4FB721BACD1B7003742D0 /* pages.pages */ = {isa = PBXFileReference; lastKnownFileType = file; name = pages.pages; path = ios/pages.pages; sourceTree = SOURCE_ROOT; };
</span><ins>+                A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AlwaysRevalidatedURLSchemes.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageVisibilityStateWithWindowChanges.mm; sourceTree = "<group>"; };
</span><span class="cx">                 A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = PageVisibilityStateWithWindowChanges.html; sourceTree = "<group>"; };
</span><span class="lines">@@ -938,6 +940,7 @@
</span><span class="cx">                                 37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
</span><span class="cx">                                 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */,
</span><span class="cx">                                 1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
</span><ins>+                                A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
</ins><span class="cx">                                 CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
</span><span class="cx">                                 C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
</span><span class="cx">                                 37D36F311B004DD400BAF5D9 /* ProvisionalURLChange.mm */,
</span><span class="lines">@@ -1781,6 +1784,7 @@
</span><span class="cx">                                 7CCE7F1B1A411AE600447C4C /* WillLoad.cpp in Sources */,
</span><span class="cx">                                 7CCE7ED71A411A7E00447C4C /* WillPerformClientRedirectToURLCrash.mm in Sources */,
</span><span class="cx">                                 7CCE7F1C1A411AE600447C4C /* WillSendSubmitEvent.cpp in Sources */,
</span><ins>+                                A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */,
</ins><span class="cx">                                 7CCE7ED81A411A7E00447C4C /* WillSendSubmitEvent.mm in Sources */,
</span><span class="cx">                                 0FE447991B76F1EB009498EB /* ParkingLot.cpp in Sources */,
</span><span class="cx">                                 7CCE7ED91A411A7E00447C4C /* WindowlessWebViewWithMedia.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaAlwaysRevalidatedURLSchemesmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm (0 => 194880)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AlwaysRevalidatedURLSchemes.mm        2016-01-12 02:12:37 UTC (rev 194880)
</span><span class="lines">@@ -0,0 +1,121 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import <WebKit/WKBrowsingContextController.h>
+#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/_WKProcessPoolConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+static NSString * const customScheme = @"custom";
+static bool isDone;
+static size_t loadsStarted;
+
+@interface AlwaysRevalidatedURLSchemeProtocol : NSURLProtocol
+@end
+
+@implementation AlwaysRevalidatedURLSchemeProtocol
+
++ (BOOL)canInitWithRequest:(NSURLRequest *)request
+{
+ return [request.URL.scheme isEqualToString:customScheme];
+}
+
++ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
+{
+ return request;
+}
+
++ (BOOL)requestIsCacheEquivalent:(NSURLRequest *)a toRequest:(NSURLRequest *)b
+{
+ return NO;
+}
+
+- (void)startLoading
+{
+ ++loadsStarted;
+
+ auto data = adoptNS([[NSData alloc] initWithBase64EncodedString:@"iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFZJREFUeF59z4EJADEIQ1F36k7u5E7ZKXeUQPACJ3wK7UNokVxVk9kHnQH7bY9hbDyDhNXgjpRLqFlo4M2GgfyJHhjq8V4agfrgPQX3JtJQGbofmCHgA/nAKks+JAjFAAAAAElFTkSuQmCC" options:0]);
+ auto response = adoptNS([[NSURLResponse alloc] initWithURL:self.request.URL MIMEType:@"image/png" expectedContentLength:[data length] textEncodingName:nil]);
+ [self.client URLProtocol:self didReceiveResponse:response.get() cacheStoragePolicy:NSURLCacheStorageNotAllowed];
+ [self.client URLProtocol:self didLoadData:data.get()];
+ [self.client URLProtocolDidFinishLoading:self];
+}
+
+- (void)stopLoading
+{
+}
+
+@end
+
+@interface AlwaysRevalidatedURLSchemesDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation AlwaysRevalidatedURLSchemesDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+ isDone = true;
+}
+
+@end
+
+TEST(WebKit2, AlwaysRevalidatedURLSchemes)
+{
+ @autoreleasepool {
+ [NSURLProtocol registerClass:[AlwaysRevalidatedURLSchemeProtocol class]];
+ [WKBrowsingContextController registerSchemeForCustomProtocol:customScheme];
+
+ auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+ [processPoolConfiguration setAlwaysRevalidatedURLSchemes:@[customScheme]];
+
+ auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+ auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ [webViewConfiguration setProcessPool:processPool.get()];
+
+ auto navigationDelegate = adoptNS([[AlwaysRevalidatedURLSchemesDelegate alloc] init]);
+ auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:webViewConfiguration.get()]);
+ [webView setNavigationDelegate:navigationDelegate.get()];
+
+ NSString *htmlString = [NSString stringWithFormat:@"<!DOCTYPE html><body><img src='%@://image'>", customScheme];
+ [webView loadHTMLString:htmlString baseURL:nil];
+ TestWebKitAPI::Util::run(&isDone);
+ EXPECT_EQ(1UL, loadsStarted);
+
+ isDone = false;
+ [webView loadHTMLString:htmlString baseURL:nil];
+ TestWebKitAPI::Util::run(&isDone);
+ EXPECT_EQ(2UL, loadsStarted);
+
+ [WKBrowsingContextController unregisterSchemeForCustomProtocol:customScheme];
+ [NSURLProtocol unregisterClass:[AlwaysRevalidatedURLSchemeProtocol class]];
+ }
+}
+
+#endif // WK_API_ENABLED
</ins></span></pre>
</div>
</div>
</body>
</html>