| Differences between
and this patch
- a/Source/WebCore/ChangeLog +31 lines
Lines 1-5 a/Source/WebCore/ChangeLog_sec1
1
2016-10-13  Youenn Fablet  <youenn@apple.com>
1
2016-10-13  Youenn Fablet  <youenn@apple.com>
2
2
3
        Make NetworkCache aware of fetch cache mode
4
        https://bugs.webkit.org/show_bug.cgi?id=163332
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Tests: imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-conditional.html
9
               imported/w3c/web-platform-tests/fetch/api/request/request-cache-default.html
10
               imported/w3c/web-platform-tests/fetch/api/request/request-cache-force-cache.html
11
               imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-cache.html
12
               imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-store.html
13
               imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html
14
               imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload.html
15
16
        * loader/cache/CachedResourceLoader.cpp:
17
        (WebCore::updateRequestAccordingCacheMode): Setting request cache policy according cache mode.
18
        Basically, these two are about the same.
19
        (WebCore::CachedResourceLoader::determineRevalidationPolicy): Making use of cache policy instead of cache mode.
20
        * platform/network/ResourceRequestBase.h: Adding new cache policies, aligned with fetch cache modes.
21
        * platform/network/cf/ResourceRequestCFNet.cpp:
22
        (WebCore::toPlatformRequestCachePolicy): If policy is not supported by CFNetwork, fallback to ReloadIgnoringCacheData.
23
        This is the best approximate we might find.
24
        (WebCore::ResourceRequest::doUpdatePlatformHTTPBody):
25
        (WebCore::ResourceRequest::doUpdateResourceRequest): Only updating cache policy, if cache policy is the default.
26
        * platform/network/cf/ResourceRequestCFNet.h:
27
        * platform/network/cocoa/ResourceRequestCocoa.mm: Doing the same modifications as for ResourceRequestCFNet.
28
        (WebCore::ResourceRequest::doUpdateResourceRequest):
29
        (WebCore::toPlatformRequestCachePolicy):
30
        (WebCore::ResourceRequest::doUpdatePlatformRequest):
31
32
2016-10-13  Youenn Fablet  <youenn@apple.com>
33
3
        Remove CachedResourceRequest::mutableResourceRequest
34
        Remove CachedResourceRequest::mutableResourceRequest
4
        https://bugs.webkit.org/show_bug.cgi?id=163277
35
        https://bugs.webkit.org/show_bug.cgi?id=163277
5
36
- a/Source/WebKit2/ChangeLog +27 lines
Lines 1-3 a/Source/WebKit2/ChangeLog_sec1
1
2016-10-13  Youenn Fablet  <youenn@apple.com>
2
3
        Make NetworkCache aware of fetch cache mode
4
        https://bugs.webkit.org/show_bug.cgi?id=163332
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Adding explicit serialization of ResourceRequest cachePolicy since it does no longer map to platform request cache policy.
9
10
        Added support for:
11
        - Bypassing entirely the network cache in case cache mode is NoStore.
12
        - requiring revalidation in case of cache hit and cache mode is NoCache.
13
        - Not using any entry if cache mode is Reload (but cache can still be updated)
14
15
        Also made sure that the ResourceRequest::cachePolicy remains the same throughout redirections.
16
17
        * NetworkProcess/NetworkResourceLoader.cpp:
18
        (WebKit::NetworkResourceLoader::canUseCache):
19
        (WebKit::NetworkResourceLoader::retrieveCacheEntry):
20
        (WebKit::NetworkResourceLoader::continueWillSendRequest):
21
        * NetworkProcess/cache/NetworkCache.cpp:
22
        (WebKit::NetworkCache::cachePolicyAllowsExpired):
23
        (WebKit::NetworkCache::makeRetrieveDecision):
24
        * Shared/mac/WebCoreArgumentCodersMac.mm:
25
        (IPC::ArgumentCoder<ResourceRequest>::encodePlatformData):
26
        (IPC::ArgumentCoder<ResourceRequest>::decodePlatformData):
27
1
2016-10-12  Chris Dumez  <cdumez@apple.com>
28
2016-10-12  Chris Dumez  <cdumez@apple.com>
2
29
3
        [Web IDL] Drop support for legacy [ConstructorConditional=*]
30
        [Web IDL] Drop support for legacy [ConstructorConditional=*]
- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp -3 / +3 lines
Lines 835-841 CachedResourceHandle<CachedResource> CachedResourceLoader::loadResource(CachedRe a/Source/WebCore/loader/cache/CachedResourceLoader.cpp_sec1
835
{
835
{
836
    auto& memoryCache = MemoryCache::singleton();
836
    auto& memoryCache = MemoryCache::singleton();
837
    ASSERT(!request.allowsCaching() || !memoryCache.resourceForRequest(request.resourceRequest(), sessionID())
837
    ASSERT(!request.allowsCaching() || !memoryCache.resourceForRequest(request.resourceRequest(), sessionID())
838
        || request.options().cache == FetchOptions::Cache::NoCache || request.options().cache == FetchOptions::Cache::NoStore || request.options().cache == FetchOptions::Cache::Reload);
838
        || request.resourceRequest().cachePolicy() == DoNotUseAnyCache || request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData || request.resourceRequest().cachePolicy() == RefreshAnyCacheData);
839
839
840
    LOG(ResourceLoading, "Loading CachedResource for '%s'.", request.resourceRequest().url().stringCenterEllipsizedToLength().latin1().data());
840
    LOG(ResourceLoading, "Loading CachedResource for '%s'.", request.resourceRequest().url().stringCenterEllipsizedToLength().latin1().data());
841
841
Lines 888-897 CachedResourceLoader::RevalidationPolicy CachedResourceLoader::determineRevalida a/Source/WebCore/loader/cache/CachedResourceLoader.cpp_sec2
888
    if (!existingResource)
888
    if (!existingResource)
889
        return Load;
889
        return Load;
890
890
891
    if (cachedResourceRequest.options().cache == FetchOptions::Cache::NoStore)
891
    if (request.cachePolicy() == DoNotUseAnyCache || request.cachePolicy() == ReloadIgnoringCacheData)
892
        return Load;
892
        return Load;
893
893
894
    if (cachedResourceRequest.options().cache == FetchOptions::Cache::Reload)
894
    if (request.cachePolicy() == RefreshAnyCacheData)
895
        return Reload;
895
        return Reload;
896
896
897
    // We already have a preload going for this URL.
897
    // We already have a preload going for this URL.
- a/Source/WebCore/loader/cache/CachedResourceRequest.cpp -2 / +2 lines
Lines 153-164 void CachedResourceRequest::updateAccordingCacheMode() a/Source/WebCore/loader/cache/CachedResourceRequest.cpp_sec1
153
153
154
    switch (m_options.cache) {
154
    switch (m_options.cache) {
155
    case FetchOptions::Cache::NoCache:
155
    case FetchOptions::Cache::NoCache:
156
        m_resourceRequest.setCachePolicy(ReloadIgnoringCacheData);
156
        m_resourceRequest.setCachePolicy(RefreshAnyCacheData);
157
        m_resourceRequest.addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
157
        m_resourceRequest.addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::maxAge0());
158
        break;
158
        break;
159
    case FetchOptions::Cache::NoStore:
159
    case FetchOptions::Cache::NoStore:
160
        m_options.cachingPolicy = CachingPolicy::DisallowCaching;
160
        m_options.cachingPolicy = CachingPolicy::DisallowCaching;
161
        m_resourceRequest.setCachePolicy(ReloadIgnoringCacheData);
161
        m_resourceRequest.setCachePolicy(DoNotUseAnyCache);
162
        m_resourceRequest.addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache());
162
        m_resourceRequest.addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::Pragma, HTTPHeaderValues::noCache());
163
        m_resourceRequest.addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache());
163
        m_resourceRequest.addHTTPHeaderFieldIfNotPresent(HTTPHeaderName::CacheControl, HTTPHeaderValues::noCache());
164
        break;
164
        break;
- a/Source/WebCore/platform/network/ResourceRequestBase.h -4 / +6 lines
Lines 36-45 a/Source/WebCore/platform/network/ResourceRequestBase.h_sec1
36
namespace WebCore {
36
namespace WebCore {
37
37
38
enum ResourceRequestCachePolicy {
38
enum ResourceRequestCachePolicy {
39
    UseProtocolCachePolicy, // normal load
39
    UseProtocolCachePolicy, // normal load, equivalent to fetch "default" cache mode.
40
    ReloadIgnoringCacheData, // reload
40
    ReloadIgnoringCacheData, // reload, equivalent to fetch "reload"cache mode.
41
    ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data
41
    ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data, equivalent to fetch "force-cache" cache mode.
42
    ReturnCacheDataDontLoad  // results of a post - allow stale data and only use cache
42
    ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache, equivalent to fetch "only-if-cached" cache mode.
43
    DoNotUseAnyCache, // Bypass the cache entirely, equivalent to fetch "no-store" cache mode.
44
    RefreshAnyCacheData, // Serve cache data only if revalidated, equivalent to fetch "no-cache" mode.
43
};
45
};
44
46
45
enum HTTPBodyUpdatePolicy {
47
enum HTTPBodyUpdatePolicy {
- a/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp -2 / +8 lines
Lines 170-175 void ResourceRequest::doUpdatePlatformRequest() a/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp_sec1
170
    m_cfRequest = adoptCF(cfRequest);
170
    m_cfRequest = adoptCF(cfRequest);
171
}
171
}
172
172
173
static inline CFURLRequestCachePolicy toPlatformRequestCachePolicy(ResourceRequestCachePolicy policy)
174
{
175
    return (CFURLRequestCachePolicy)((policy <= ReturnCacheDataDontLoad) ? policy : ReloadIgnoringCacheData);
176
}
177
173
void ResourceRequest::doUpdatePlatformHTTPBody()
178
void ResourceRequest::doUpdatePlatformHTTPBody()
174
{
179
{
175
    CFMutableURLRequestRef cfRequest;
180
    CFMutableURLRequestRef cfRequest;
Lines 180-186 void ResourceRequest::doUpdatePlatformHTTPBody() a/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp_sec2
180
        cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
185
        cfRequest = CFURLRequestCreateMutableCopy(0, m_cfRequest.get());
181
        CFURLRequestSetURL(cfRequest, url.get());
186
        CFURLRequestSetURL(cfRequest, url.get());
182
        CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get());
187
        CFURLRequestSetMainDocumentURL(cfRequest, firstPartyForCookies.get());
183
        CFURLRequestSetCachePolicy(cfRequest, (CFURLRequestCachePolicy)cachePolicy());
188
        CFURLRequestSetCachePolicy(cfRequest, toPlatformRequestCachePolicy(cachePolicy()));
184
        CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval());
189
        CFURLRequestSetTimeoutInterval(cfRequest, timeoutInterval());
185
    } else
190
    } else
186
        cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get());
191
        cfRequest = CFURLRequestCreateMutable(0, url.get(), (CFURLRequestCachePolicy)cachePolicy(), timeoutInterval(), firstPartyForCookies.get());
Lines 211-217 void ResourceRequest::doUpdateResourceRequest() a/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp_sec3
211
216
212
    m_url = CFURLRequestGetURL(m_cfRequest.get());
217
    m_url = CFURLRequestGetURL(m_cfRequest.get());
213
218
214
    m_cachePolicy = (ResourceRequestCachePolicy)CFURLRequestGetCachePolicy(m_cfRequest.get());
219
    if (!m_cachePolicy)
220
        m_cachePolicy = (ResourceRequestCachePolicy)CFURLRequestGetCachePolicy(m_cfRequest.get());
215
    m_timeoutInterval = CFURLRequestGetTimeoutInterval(m_cfRequest.get());
221
    m_timeoutInterval = CFURLRequestGetTimeoutInterval(m_cfRequest.get());
216
    m_firstPartyForCookies = CFURLRequestGetMainDocumentURL(m_cfRequest.get());
222
    m_firstPartyForCookies = CFURLRequestGetMainDocumentURL(m_cfRequest.get());
217
    if (CFStringRef method = CFURLRequestCopyHTTPRequestMethod(m_cfRequest.get())) {
223
    if (CFStringRef method = CFURLRequestCopyHTTPRequestMethod(m_cfRequest.get())) {
- a/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h -1 / +2 lines
Lines 20-32 a/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h_sec1
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
24
 */
25
25
26
#pragma once
26
#pragma once
27
27
28
#include "CFNetworkSPI.h"
28
#include "CFNetworkSPI.h"
29
#include "ResourceLoadPriority.h"
29
#include "ResourceLoadPriority.h"
30
#include "ResourceRequestBase.h"
30
31
31
namespace WebCore {
32
namespace WebCore {
32
33
- a/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm -2 / +9 lines
Lines 64-70 CFURLRequestRef ResourceRequest::cfURLRequest(HTTPBodyUpdatePolicy bodyPolicy) c a/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm_sec1
64
void ResourceRequest::doUpdateResourceRequest()
64
void ResourceRequest::doUpdateResourceRequest()
65
{
65
{
66
    m_url = [m_nsRequest.get() URL];
66
    m_url = [m_nsRequest.get() URL];
67
    m_cachePolicy = (ResourceRequestCachePolicy)[m_nsRequest.get() cachePolicy];
67
68
    if (!m_cachePolicy)
69
        m_cachePolicy = (ResourceRequestCachePolicy)[m_nsRequest.get() cachePolicy];
68
    m_timeoutInterval = [m_nsRequest.get() timeoutInterval];
70
    m_timeoutInterval = [m_nsRequest.get() timeoutInterval];
69
    m_firstPartyForCookies = [m_nsRequest.get() mainDocumentURL];
71
    m_firstPartyForCookies = [m_nsRequest.get() mainDocumentURL];
70
72
Lines 112-117 void ResourceRequest::doUpdateResourceHTTPBody() a/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm_sec2
112
    }
114
    }
113
}
115
}
114
116
117
static inline NSURLRequestCachePolicy toPlatformRequestCachePolicy(ResourceRequestCachePolicy policy)
118
{
119
    return (NSURLRequestCachePolicy)((policy <= ReturnCacheDataDontLoad) ? policy : ReloadIgnoringCacheData);
120
}
121
115
void ResourceRequest::doUpdatePlatformRequest()
122
void ResourceRequest::doUpdatePlatformRequest()
116
{
123
{
117
    if (isNull()) {
124
    if (isNull()) {
Lines 132-138 void ResourceRequest::doUpdatePlatformRequest() a/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm_sec3
132
    if (ResourceRequest::resourcePrioritiesEnabled())
139
    if (ResourceRequest::resourcePrioritiesEnabled())
133
        CFURLRequestSetRequestPriority([nsRequest _CFURLRequest], toPlatformRequestPriority(priority()));
140
        CFURLRequestSetRequestPriority([nsRequest _CFURLRequest], toPlatformRequestPriority(priority()));
134
141
135
    [nsRequest setCachePolicy:(NSURLRequestCachePolicy)cachePolicy()];
142
    [nsRequest setCachePolicy:toPlatformRequestCachePolicy(cachePolicy())];
136
    _CFURLRequestSetProtocolProperty([nsRequest _CFURLRequest], kCFURLRequestAllowAllPOSTCaching, kCFBooleanTrue);
143
    _CFURLRequestSetProtocolProperty([nsRequest _CFURLRequest], kCFURLRequestAllowAllPOSTCaching, kCFBooleanTrue);
137
144
138
    double timeoutInterval = ResourceRequestBase::timeoutInterval();
145
    double timeoutInterval = ResourceRequestBase::timeoutInterval();
- a/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp -1 / +6 lines
Lines 122-127 bool NetworkResourceLoader::canUseCache(const ResourceRequest& request) const a/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp_sec1
122
        return false;
122
        return false;
123
    if (!request.url().protocolIsInHTTPFamily())
123
    if (!request.url().protocolIsInHTTPFamily())
124
        return false;
124
        return false;
125
    if (originalRequest().cachePolicy() == WebCore::DoNotUseAnyCache)
126
        return false;
125
127
126
    return true;
128
    return true;
127
}
129
}
Lines 188-194 void NetworkResourceLoader::retrieveCacheEntry(const ResourceRequest& request) a/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp_sec2
188
            loader->startNetworkLoad(request);
190
            loader->startNetworkLoad(request);
189
            return;
191
            return;
190
        }
192
        }
191
        if (entry->needsValidation()) {
193
        if (entry->needsValidation() || request.cachePolicy() == WebCore::RefreshAnyCacheData) {
192
            loader->validateCacheEntry(WTFMove(entry));
194
            loader->validateCacheEntry(WTFMove(entry));
193
            return;
195
            return;
194
        }
196
        }
Lines 471-476 void NetworkResourceLoader::continueWillSendRequest(ResourceRequest&& newRequest a/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp_sec3
471
{
473
{
472
    RELEASE_LOG_IF_ALLOWED("continueWillSendRequest: (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier);
474
    RELEASE_LOG_IF_ALLOWED("continueWillSendRequest: (pageID = %" PRIu64 ", frameID = %" PRIu64 ", resourceID = %" PRIu64 ")", m_parameters.webPageID, m_parameters.webFrameID, m_parameters.identifier);
473
475
476
    // If there is a match in the network cache, we need to reuse the original cache policy.
477
    newRequest.setCachePolicy(originalRequest().cachePolicy());
478
474
#if ENABLE(NETWORK_CACHE)
479
#if ENABLE(NETWORK_CACHE)
475
    if (m_isWaitingContinueWillSendRequestForCachedRedirect) {
480
    if (m_isWaitingContinueWillSendRequestForCachedRedirect) {
476
        LOG(NetworkCache, "(NetworkProcess) Retrieving cached redirect");
481
        LOG(NetworkCache, "(NetworkProcess) Retrieving cached redirect");
- a/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp -1 / +6 lines
Lines 136-144 static bool cachePolicyAllowsExpired(WebCore::ResourceRequestCachePolicy policy) a/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp_sec1
136
        return true;
136
        return true;
137
    case WebCore::UseProtocolCachePolicy:
137
    case WebCore::UseProtocolCachePolicy:
138
    case WebCore::ReloadIgnoringCacheData:
138
    case WebCore::ReloadIgnoringCacheData:
139
    case WebCore::RefreshAnyCacheData:
140
        return false;
141
    case WebCore::DoNotUseAnyCache:
142
        ASSERT_NOT_REACHED();
139
        return false;
143
        return false;
140
    }
144
    }
141
    ASSERT_NOT_REACHED();
142
    return false;
145
    return false;
143
}
146
}
144
147
Lines 198-203 static UseDecision makeUseDecision(const Entry& entry, const WebCore::ResourceRe a/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp_sec2
198
201
199
static RetrieveDecision makeRetrieveDecision(const WebCore::ResourceRequest& request)
202
static RetrieveDecision makeRetrieveDecision(const WebCore::ResourceRequest& request)
200
{
203
{
204
    ASSERT(request.cachePolicy() != WebCore::DoNotUseAnyCache);
205
201
    // FIXME: Support HEAD requests.
206
    // FIXME: Support HEAD requests.
202
    if (request.httpMethod() != "GET")
207
    if (request.httpMethod() != "GET")
203
        return RetrieveDecision::NoDueToHTTPMethod;
208
        return RetrieveDecision::NoDueToHTTPMethod;
- a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm +6 lines
Lines 77-82 void ArgumentCoder<ResourceRequest>::encodePlatformData(Encoder& encoder, const a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm_sec1
77
    // The fallback array is part of NSURLRequest, but it is not encoded by WKNSURLRequestCreateSerializableRepresentation.
77
    // The fallback array is part of NSURLRequest, but it is not encoded by WKNSURLRequestCreateSerializableRepresentation.
78
    encoder << resourceRequest.responseContentDispositionEncodingFallbackArray();
78
    encoder << resourceRequest.responseContentDispositionEncodingFallbackArray();
79
    encoder.encodeEnum(resourceRequest.requester());
79
    encoder.encodeEnum(resourceRequest.requester());
80
    encoder.encodeEnum(resourceRequest.cachePolicy());
80
}
81
}
81
82
82
bool ArgumentCoder<ResourceRequest>::decodePlatformData(Decoder& decoder, ResourceRequest& resourceRequest)
83
bool ArgumentCoder<ResourceRequest>::decodePlatformData(Decoder& decoder, ResourceRequest& resourceRequest)
Lines 115-120 bool ArgumentCoder<ResourceRequest>::decodePlatformData(Decoder& decoder, Resour a/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm_sec2
115
        return false;
116
        return false;
116
    resourceRequest.setRequester(requester);
117
    resourceRequest.setRequester(requester);
117
118
119
    ResourceRequestCachePolicy cachePolicy;
120
    if (!decoder.decodeEnum(cachePolicy))
121
        return false;
122
    resourceRequest.setCachePolicy(cachePolicy);
123
118
    return true;
124
    return true;
119
}
125
}
120
126
- a/LayoutTests/ChangeLog +13 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2016-10-13  Youenn Fablet  <youenn@apple.com>
2
3
        Make NetworkCache aware of fetch cache mode
4
        https://bugs.webkit.org/show_bug.cgi?id=163332
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * platform/ios-simulator/TestExpectations:
9
        * platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached-expected.txt: Added.
10
        * platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload-expected.txt: Added.
11
        * platform/win/TestExpectations:
12
        * platform/wk2/TestExpectations:
13
1
2016-10-13  Antti Koivisto  <antti@apple.com>
14
2016-10-13  Antti Koivisto  <antti@apple.com>
2
15
3
        Support scoped style for user agent shadow trees
16
        Support scoped style for user agent shadow trees
- a/LayoutTests/imported/w3c/ChangeLog +35 lines
Lines 1-3 a/LayoutTests/imported/w3c/ChangeLog_sec1
1
2016-10-13  Youenn Fablet  <youenn@apple.com>
2
3
        Make NetworkCache aware of fetch cache mode
4
        https://bugs.webkit.org/show_bug.cgi?id=163332
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Splitting web-platform-tests/fetch/api/request/request-cache.html in several files so that running the individual test files
9
        is more manageable.
10
11
        * web-platform-tests/fetch/api/request/request-cache-default-conditional-expected.txt: Added.
12
        * web-platform-tests/fetch/api/request/request-cache-default-conditional.html: Added.
13
        * web-platform-tests/fetch/api/request/request-cache-default-expected.txt: Added.
14
        * web-platform-tests/fetch/api/request/request-cache-default.html: Added.
15
        * web-platform-tests/fetch/api/request/request-cache-expected.txt: Removed.
16
        * web-platform-tests/fetch/api/request/request-cache-force-cache-expected.txt: Added.
17
        * web-platform-tests/fetch/api/request/request-cache-force-cache.html: Added.
18
        * web-platform-tests/fetch/api/request/request-cache-no-cache-expected.txt: Added.
19
        * web-platform-tests/fetch/api/request/request-cache-no-cache.html: Added.
20
        * web-platform-tests/fetch/api/request/request-cache-no-store-expected.txt: Added.
21
        * web-platform-tests/fetch/api/request/request-cache-no-store.html: Added.
22
        * web-platform-tests/fetch/api/request/request-cache-only-if-cached-expected.txt: Added.
23
        * web-platform-tests/fetch/api/request/request-cache-only-if-cached.html: Added.
24
        * web-platform-tests/fetch/api/request/request-cache-reload-expected.txt: Added.
25
        * web-platform-tests/fetch/api/request/request-cache-reload.html: Added.
26
        * web-platform-tests/fetch/api/request/request-cache.html: Removed.
27
        * web-platform-tests/fetch/api/request/request-cache.js: Added.
28
        (base_path):
29
        (make_url):
30
        (expected_status):
31
        (expected_response_text):
32
        (server_state):
33
        (run_next_step):
34
        (make_test):
35
1
2016-10-11  Chris Dumez  <cdumez@apple.com>
36
2016-10-11  Chris Dumez  <cdumez@apple.com>
2
37
3
        select.options may return too many option elements
38
        select.options may return too many option elements
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-conditional-expected.txt +42 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-conditional-expected.txt_sec1
1
2
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response 
3
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and stale response 
4
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response 
5
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and fresh response 
6
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response 
7
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and stale response 
8
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response 
9
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and fresh response 
10
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response 
11
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and stale response 
12
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response 
13
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response 
14
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response 
15
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and stale response 
16
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response 
17
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response 
18
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response 
19
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and stale response 
20
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response 
21
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response 
22
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response 
23
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and stale response 
24
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response 
25
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response 
26
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response 
27
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and stale response 
28
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response 
29
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response 
30
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response 
31
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and stale response 
32
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response 
33
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response 
34
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response 
35
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and stale response 
36
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response 
37
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response 
38
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response 
39
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and stale response 
40
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response 
41
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response 
42
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-conditional.html +180 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-conditional.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache - default with conditional requests</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
18
        state: "stale",
19
        request_cache: ["default", "default"],
20
        request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
21
        expected_validation_headers: [false, false],
22
        expected_no_cache_headers: [false, true],
23
      },
24
      {
25
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
26
        state: "fresh",
27
        request_cache: ["default", "default"],
28
        request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
29
        expected_validation_headers: [false, false],
30
        expected_no_cache_headers: [false, true],
31
      },
32
      {
33
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
34
        state: "stale",
35
        request_cache: ["default", "default"],
36
        request_headers: [{"If-Modified-Since": now.toGMTString()}, {}],
37
        expected_validation_headers: [false, false],
38
        expected_no_cache_headers: [true, false],
39
      },
40
      {
41
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
42
        state: "fresh",
43
        request_cache: ["default", "default"],
44
        request_headers: [{"If-Modified-Since": now.toGMTString()}, {}],
45
        expected_validation_headers: [false, false],
46
        expected_no_cache_headers: [true, false],
47
      },
48
      {
49
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
50
        state: "stale",
51
        request_cache: ["default", "default"],
52
        request_headers: [{}, {"If-None-Match": '"foo"'}],
53
        expected_validation_headers: [false, false],
54
        expected_no_cache_headers: [false, true],
55
      },
56
      {
57
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
58
        state: "fresh",
59
        request_cache: ["default", "default"],
60
        request_headers: [{}, {"If-None-Match": '"foo"'}],
61
        expected_validation_headers: [false, false],
62
        expected_no_cache_headers: [false, true],
63
      },
64
      {
65
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
66
        state: "stale",
67
        request_cache: ["default", "default"],
68
        request_headers: [{"If-None-Match": '"foo"'}, {}],
69
        expected_validation_headers: [false, false],
70
        expected_no_cache_headers: [true, false],
71
      },
72
      {
73
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
74
        state: "fresh",
75
        request_cache: ["default", "default"],
76
        request_headers: [{"If-None-Match": '"foo"'}, {}],
77
        expected_validation_headers: [false, false],
78
        expected_no_cache_headers: [true, false],
79
      },
80
      {
81
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
82
        state: "stale",
83
        request_cache: ["default", "default"],
84
        request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
85
        expected_validation_headers: [false, false],
86
        expected_no_cache_headers: [false, true],
87
      },
88
      {
89
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
90
        state: "fresh",
91
        request_cache: ["default", "default"],
92
        request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
93
        expected_validation_headers: [false, false],
94
        expected_no_cache_headers: [false, true],
95
      },
96
      {
97
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
98
        state: "stale",
99
        request_cache: ["default", "default"],
100
        request_headers: [{"If-Unmodified-Since": now.toGMTString()}, {}],
101
        expected_validation_headers: [false, false],
102
        expected_no_cache_headers: [true, false],
103
      },
104
      {
105
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
106
        state: "fresh",
107
        request_cache: ["default", "default"],
108
        request_headers: [{"If-Unmodified-Since": now.toGMTString()}, {}],
109
        expected_validation_headers: [false, false],
110
        expected_no_cache_headers: [true, false],
111
      },
112
      {
113
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
114
        state: "stale",
115
        request_cache: ["default", "default"],
116
        request_headers: [{}, {"If-Match": '"foo"'}],
117
        expected_validation_headers: [false, false],
118
        expected_no_cache_headers: [false, true],
119
      },
120
      {
121
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
122
        state: "fresh",
123
        request_cache: ["default", "default"],
124
        request_headers: [{}, {"If-Match": '"foo"'}],
125
        expected_validation_headers: [false, false],
126
        expected_no_cache_headers: [false, true],
127
      },
128
      {
129
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
130
        state: "stale",
131
        request_cache: ["default", "default"],
132
        request_headers: [{"If-Match": '"foo"'}, {}],
133
        expected_validation_headers: [false, false],
134
        expected_no_cache_headers: [true, false],
135
      },
136
      {
137
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
138
        state: "fresh",
139
        request_cache: ["default", "default"],
140
        request_headers: [{"If-Match": '"foo"'}, {}],
141
        expected_validation_headers: [false, false],
142
        expected_no_cache_headers: [true, false],
143
      },
144
      {
145
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
146
        state: "stale",
147
        request_cache: ["default", "default"],
148
        request_headers: [{}, {"If-Range": '"foo"'}],
149
        expected_validation_headers: [false, false],
150
        expected_no_cache_headers: [false, true],
151
      },
152
      {
153
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
154
        state: "fresh",
155
        request_cache: ["default", "default"],
156
        request_headers: [{}, {"If-Range": '"foo"'}],
157
        expected_validation_headers: [false, false],
158
        expected_no_cache_headers: [false, true],
159
      },
160
      {
161
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
162
        state: "stale",
163
        request_cache: ["default", "default"],
164
        request_headers: [{"If-Range": '"foo"'}, {}],
165
        expected_validation_headers: [false, false],
166
        expected_no_cache_headers: [true, false],
167
      },
168
      {
169
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
170
        state: "fresh",
171
        request_cache: ["default", "default"],
172
        request_headers: [{"If-Range": '"foo"'}, {}],
173
        expected_validation_headers: [false, false],
174
        expected_no_cache_headers: [true, false],
175
      },
176
    ];
177
    run_tests(tests);
178
    </script>
179
  </body>
180
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-expected.txt +10 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default-expected.txt_sec1
1
2
PASS RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses with Etag and stale response 
3
PASS RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses with date and stale response 
4
PASS RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with Etag and fresh response 
5
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 
6
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and stale response 
7
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with date and stale response 
8
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and fresh response 
9
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with date and fresh response 
10
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default.html +50 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-default.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache - default</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses',
18
        state: "stale",
19
        request_cache: ["default", "default"],
20
        expected_validation_headers: [false, true],
21
        expected_no_cache_headers: [false, false],
22
      },
23
      {
24
        name: 'RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists',
25
        state: "fresh",
26
        request_cache: ["default", "default"],
27
        expected_validation_headers: [false],
28
        expected_no_cache_headers: [false],
29
      },
30
      {
31
        name: 'Responses with the "Cache-Control: no-store" header are not stored in the cache',
32
        state: "stale",
33
        cache_control: "no-store",
34
        request_cache: ["default", "default"],
35
        expected_validation_headers: [false, false],
36
        expected_no_cache_headers: [false, false],
37
      },
38
      {
39
        name: 'Responses with the "Cache-Control: no-store" header are not stored in the cache',
40
        state: "fresh",
41
        cache_control: "no-store",
42
        request_cache: ["default", "default"],
43
        expected_validation_headers: [false, false],
44
        expected_no_cache_headers: [false, false],
45
      },
46
    ];
47
    run_tests(tests);
48
    </script>
49
  </body>
50
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-expected.txt -104 lines
Lines 1-104 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-expected.txt_sec1
1
2
PASS RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses with Etag and stale response 
3
PASS RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses with date and stale response 
4
PASS RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists with Etag and fresh response 
5
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 
6
PASS RequestCache "no-cache" mode revalidates stale responses found in the cache with Etag and stale response 
7
PASS RequestCache "no-cache" mode revalidates stale responses found in the cache with date and stale response 
8
PASS RequestCache "no-cache" mode revalidates fresh responses found in the cache with Etag and fresh response 
9
PASS RequestCache "no-cache" mode revalidates fresh responses found in the cache with date and fresh response 
10
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Etag and stale response 
11
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with date and stale response 
12
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Etag and fresh response 
13
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with date and fresh response 
14
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 
15
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 date and stale response 
16
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 fresh response 
17
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 date and fresh response 
18
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Etag and stale response 
19
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with date and stale response 
20
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Etag and fresh response 
21
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with date and fresh response 
22
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and stale response 
23
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with date and stale response 
24
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and fresh response 
25
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with date and fresh response 
26
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response 
27
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with date and stale response 
28
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response 
29
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with date and fresh response 
30
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 
31
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 
32
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"
33
FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and fresh response promise_test: Unhandled rejection with value: object "TypeError: Type error"
34
FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and stale response promise_test: Unhandled rejection with value: object "TypeError: Type error"
35
FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and stale response promise_test: Unhandled rejection with value: object "TypeError: Type error"
36
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and fresh response 
37
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and fresh response 
38
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and stale response 
39
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and stale response 
40
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 
41
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 
42
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 
43
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 
44
PASS RequestCache "no-store" mode does not store the response in the cache with Etag and stale response 
45
PASS RequestCache "no-store" mode does not store the response in the cache with date and stale response 
46
PASS RequestCache "no-store" mode does not store the response in the cache with Etag and fresh response 
47
PASS RequestCache "no-store" mode does not store the response in the cache with date and fresh response 
48
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response 
49
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and stale response 
50
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response 
51
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and fresh response 
52
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and stale response 
53
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and stale response 
54
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with Etag and fresh response 
55
PASS RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store" with date and fresh response 
56
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response 
57
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and stale response 
58
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response 
59
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response 
60
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and stale response 
61
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and stale response 
62
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with Etag and fresh response 
63
PASS RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store" with date and fresh response 
64
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response 
65
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and stale response 
66
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response 
67
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response 
68
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and stale response 
69
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and stale response 
70
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with Etag and fresh response 
71
PASS RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store" with date and fresh response 
72
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response 
73
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and stale response 
74
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response 
75
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response 
76
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and stale response 
77
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and stale response 
78
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with Etag and fresh response 
79
PASS RequestCache "default" mode with an If-Match header is treated similarly to "no-store" with date and fresh response 
80
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response 
81
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and stale response 
82
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response 
83
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response 
84
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and stale response 
85
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and stale response 
86
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with Etag and fresh response 
87
PASS RequestCache "default" mode with an If-Range header is treated similarly to "no-store" with date and fresh response 
88
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and stale response 
89
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with date and stale response 
90
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with Etag and fresh response 
91
PASS Responses with the "Cache-Control: no-store" header are not stored in the cache with date and fresh response 
92
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response 
93
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response 
94
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response 
95
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response 
96
PASS RequestCache "reload" mode does store the response in the cache with Etag and stale response 
97
PASS RequestCache "reload" mode does store the response in the cache with date and stale response 
98
FAIL RequestCache "reload" mode does store the response in the cache with Etag and fresh response assert_equals: expected 1 but got 2
99
FAIL RequestCache "reload" mode does store the response in the cache with date and fresh response assert_equals: expected 1 but got 2
100
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and stale response 
101
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and stale response 
102
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response 
103
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and fresh response 
104
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-force-cache-expected.txt +18 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-force-cache-expected.txt_sec1
1
2
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with Etag and stale response 
3
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses with date and stale response 
4
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with Etag and fresh response 
5
PASS RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses with date and fresh response 
6
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 
7
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 date and stale response 
8
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 fresh response 
9
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 date and fresh response 
10
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Etag and stale response 
11
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with date and stale response 
12
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with Etag and fresh response 
13
PASS RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary with date and fresh response 
14
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and stale response 
15
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with date and stale response 
16
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with Etag and fresh response 
17
PASS RequestCache "force-cache" stores the response in the cache if it goes to the network with date and fresh response 
18
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-force-cache.html +78 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-force-cache.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache - force-cache</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses',
18
        state: "stale",
19
        request_cache: ["default", "force-cache"],
20
        expected_validation_headers: [false],
21
        expected_no_cache_headers: [false],
22
      },
23
      {
24
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses',
25
        state: "fresh",
26
        request_cache: ["default", "force-cache"],
27
        expected_validation_headers: [false],
28
        expected_no_cache_headers: [false],
29
      },
30
      {
31
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found',
32
        state: "stale",
33
        request_cache: ["force-cache"],
34
        expected_validation_headers: [false],
35
        expected_no_cache_headers: [false],
36
      },
37
      {
38
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found',
39
        state: "fresh",
40
        request_cache: ["force-cache"],
41
        expected_validation_headers: [false],
42
        expected_no_cache_headers: [false],
43
      },
44
      {
45
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary',
46
        state: "stale",
47
        vary: "*",
48
        request_cache: ["default", "force-cache"],
49
        expected_validation_headers: [false, true],
50
        expected_no_cache_headers: [false, false],
51
      },
52
      {
53
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary',
54
        state: "fresh",
55
        vary: "*",
56
        request_cache: ["default", "force-cache"],
57
        expected_validation_headers: [false, true],
58
        expected_no_cache_headers: [false, false],
59
      },
60
      {
61
        name: 'RequestCache "force-cache" stores the response in the cache if it goes to the network',
62
        state: "stale",
63
        request_cache: ["force-cache", "default"],
64
        expected_validation_headers: [false, true],
65
        expected_no_cache_headers: [false, false],
66
      },
67
      {
68
        name: 'RequestCache "force-cache" stores the response in the cache if it goes to the network',
69
        state: "fresh",
70
        request_cache: ["force-cache", "default"],
71
        expected_validation_headers: [false],
72
        expected_no_cache_headers: [false],
73
      },
74
    ];
75
    run_tests(tests);
76
    </script>
77
  </body>
78
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-cache-expected.txt +6 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-cache-expected.txt_sec1
1
2
PASS RequestCache "no-cache" mode revalidates stale responses found in the cache with Etag and stale response 
3
PASS RequestCache "no-cache" mode revalidates stale responses found in the cache with date and stale response 
4
PASS RequestCache "no-cache" mode revalidates fresh responses found in the cache with Etag and fresh response 
5
PASS RequestCache "no-cache" mode revalidates fresh responses found in the cache with date and fresh response 
6
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-cache.html +36 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-cache.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache : no-cache</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "no-cache" mode revalidates stale responses found in the cache',
18
        state: "stale",
19
        request_cache: ["default", "no-cache"],
20
        expected_validation_headers: [false, true],
21
        expected_no_cache_headers: [false, false],
22
        expected_max_age_headers: [false, true],
23
      },
24
      {
25
        name: 'RequestCache "no-cache" mode revalidates fresh responses found in the cache',
26
        state: "fresh",
27
        request_cache: ["default", "no-cache"],
28
        expected_validation_headers: [false, true],
29
        expected_no_cache_headers: [false, false],
30
        expected_max_age_headers: [false, true],
31
      },
32
    ];
33
    run_tests(tests);
34
    </script>
35
  </body>
36
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-store-expected.txt +10 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-store-expected.txt_sec1
1
2
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 
3
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 
4
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 
5
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 
6
PASS RequestCache "no-store" mode does not store the response in the cache with Etag and stale response 
7
PASS RequestCache "no-store" mode does not store the response in the cache with date and stale response 
8
PASS RequestCache "no-store" mode does not store the response in the cache with Etag and fresh response 
9
PASS RequestCache "no-store" mode does not store the response in the cache with date and fresh response 
10
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-store.html +48 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-no-store.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache - no store</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless',
18
        state: "stale",
19
        request_cache: ["default", "no-store"],
20
        expected_validation_headers: [false, false],
21
        expected_no_cache_headers: [false, true],
22
      },
23
      {
24
        name: 'RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless',
25
        state: "fresh",
26
        request_cache: ["default", "no-store"],
27
        expected_validation_headers: [false, false],
28
        expected_no_cache_headers: [false, true],
29
      },
30
      {
31
        name: 'RequestCache "no-store" mode does not store the response in the cache',
32
        state: "stale",
33
        request_cache: ["no-store", "default"],
34
        expected_validation_headers: [false, false],
35
        expected_no_cache_headers: [true, false],
36
      },
37
      {
38
        name: 'RequestCache "no-store" mode does not store the response in the cache',
39
        state: "fresh",
40
        request_cache: ["no-store", "default"],
41
        expected_validation_headers: [false, false],
42
        expected_no_cache_headers: [true, false],
43
      },
44
    ];
45
    run_tests(tests);
46
    </script>
47
  </body>
48
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached-expected.txt +24 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached-expected.txt_sec1
1
CONSOLE MESSAGE: Unsafe attempt to load URL http://127.0.0.1:8800/fetch/api/request/resources/cache.py?token=2ea4f431-f8b9-4e0e-b2ab-5c8c14d9fddd&content=0.38709557547171725&tag=0.479555361588907&expires=Tue,%2003%20Oct%202017%2022:00:00%20GMT from frame with URL http://localhost:8800/fetch/api/request/request-cache-only-if-cached.html. Domains, protocols and ports must match.
2
3
CONSOLE MESSAGE: Unsafe attempt to load URL http://127.0.0.1:8800/fetch/api/request/resources/cache.py?token=d8c7da3d-d121-44ce-9de7-cfee3b6a3737&content=0.797971561144814&date=Thu,%2013%20Oct%202016%2009:15:42%20GMT&expires=Tue,%2003%20Oct%202017%2022:00:00%20GMT from frame with URL http://localhost:8800/fetch/api/request/request-cache-only-if-cached.html. Domains, protocols and ports must match.
4
5
CONSOLE MESSAGE: Unsafe attempt to load URL http://127.0.0.1:8800/fetch/api/request/resources/cache.py?token=40ec0908-6ae7-44cf-b2ed-9eb5620a6f7c&content=0.4833112948629348&tag=0.9322512369284536&expires=Sat,%2003%20Oct%202015%2022:00:00%20GMT from frame with URL http://localhost:8800/fetch/api/request/request-cache-only-if-cached.html. Domains, protocols and ports must match.
6
7
CONSOLE MESSAGE: Unsafe attempt to load URL http://127.0.0.1:8800/fetch/api/request/resources/cache.py?token=90f850f5-f936-4654-abdc-4568f11f59a3&content=0.030517910813487314&date=Thu,%2013%20Oct%202016%2009:15:42%20GMT&expires=Sat,%2003%20Oct%202015%2022:00:00%20GMT from frame with URL http://localhost:8800/fetch/api/request/request-cache-only-if-cached.html. Domains, protocols and ports must match.
8
9
10
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response 
11
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with date and stale response 
12
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response 
13
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with date and fresh response 
14
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 
15
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 
16
PASS RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and fresh response 
17
PASS RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and fresh response 
18
PASS RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and stale response 
19
PASS RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and stale response 
20
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and fresh response 
21
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and fresh response 
22
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and stale response 
23
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and stale response 
24
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html +76 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache - only-if-cached</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses',
18
        state: "stale",
19
        request_cache: ["default", "only-if-cached"],
20
        expected_validation_headers: [false],
21
        expected_no_cache_headers: [false]
22
      },
23
      {
24
        name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses',
25
        state: "fresh",
26
        request_cache: ["default", "only-if-cached"],
27
        expected_validation_headers: [false],
28
        expected_no_cache_headers: [false]
29
      },
30
      {
31
        name: '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',
32
        state: "fresh",
33
        request_cache: ["only-if-cached"],
34
        response: ["error"],
35
        expected_validation_headers: [],
36
        expected_no_cache_headers: []
37
      },
38
      {
39
        name: 'RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content',
40
        state: "fresh",
41
        request_cache: ["default", "only-if-cached"],
42
        redirect: "same-origin",
43
        expected_validation_headers: [false, false],
44
        expected_no_cache_headers: [false, false],
45
      },
46
      {
47
        name: 'RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content',
48
        state: "stale",
49
        request_cache: ["default", "only-if-cached"],
50
        redirect: "same-origin",
51
        expected_validation_headers: [false, false],
52
        expected_no_cache_headers: [false, false],
53
      },
54
      {
55
        name: 'RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects',
56
        state: "fresh",
57
        request_cache: ["default", "only-if-cached"],
58
        redirect: "cross-origin",
59
        response: [null, "error"],
60
        expected_validation_headers: [false, false],
61
        expected_no_cache_headers: [false, false],
62
      },
63
      {
64
        name: 'RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects',
65
        state: "stale",
66
        request_cache: ["default", "only-if-cached"],
67
        redirect: "cross-origin",
68
        response: [null, "error"],
69
        expected_validation_headers: [false, false],
70
        expected_no_cache_headers: [false, false],
71
      },
72
    ];
73
    run_tests(tests);
74
    </script>
75
  </body>
76
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload-expected.txt +14 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload-expected.txt_sec1
1
2
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response 
3
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response 
4
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response 
5
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response 
6
PASS RequestCache "reload" mode does store the response in the cache with Etag and stale response 
7
PASS RequestCache "reload" mode does store the response in the cache with date and stale response 
8
PASS RequestCache "reload" mode does store the response in the cache with Etag and fresh response 
9
PASS RequestCache "reload" mode does store the response in the cache with date and fresh response 
10
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and stale response 
11
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and stale response 
12
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response 
13
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and fresh response 
14
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload.html +62 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache - reload</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <script src="/resources/testharness.js"></script>
8
    <script src="/resources/testharnessreport.js"></script>
9
    <script src="/common/utils.js"></script>
10
    <script src="/common/get-host-info.sub.js"></script>
11
    <script src="request-cache.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var tests = [
16
      {
17
        name: 'RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless',
18
        state: "stale",
19
        request_cache: ["default", "reload"],
20
        expected_validation_headers: [false, false],
21
        expected_no_cache_headers: [false, true],
22
      },
23
      {
24
        name: 'RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless',
25
        state: "fresh",
26
        request_cache: ["default", "reload"],
27
        expected_validation_headers: [false, false],
28
        expected_no_cache_headers: [false, true],
29
      },
30
      {
31
        name: 'RequestCache "reload" mode does store the response in the cache',
32
        state: "stale",
33
        request_cache: ["reload", "default"],
34
        expected_validation_headers: [false, true],
35
        expected_no_cache_headers: [true, false],
36
      },
37
      {
38
        name: 'RequestCache "reload" mode does store the response in the cache',
39
        state: "fresh",
40
        request_cache: ["reload", "default"],
41
        expected_validation_headers: [false],
42
        expected_no_cache_headers: [true],
43
      },
44
      {
45
        name: 'RequestCache "reload" mode does store the response in the cache even if a previous response is already stored',
46
        state: "stale",
47
        request_cache: ["default", "reload", "default"],
48
        expected_validation_headers: [false, false, true],
49
        expected_no_cache_headers: [false, true, false],
50
      },
51
      {
52
        name: 'RequestCache "reload" mode does store the response in the cache even if a previous response is already stored',
53
        state: "fresh",
54
        request_cache: ["default", "reload", "default"],
55
        expected_validation_headers: [false, false],
56
        expected_no_cache_headers: [false, true],
57
      },
58
    ];
59
    run_tests(tests);
60
    </script>
61
  </body>
62
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache.html -626 lines
Lines 1-626 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache.html_sec1
1
<!doctype html>
2
<html>
3
  <head>
4
    <meta charset="utf-8">
5
    <title>Request cache</title>
6
    <meta name="help" href="https://fetch.spec.whatwg.org/#request">
7
    <meta name="timeout" content="long">
8
    <script src="/resources/testharness.js"></script>
9
    <script src="/resources/testharnessreport.js"></script>
10
    <script src="/common/utils.js"></script>
11
    <script src="/common/get-host-info.sub.js"></script>
12
  </head>
13
  <body>
14
    <script>
15
    var now = new Date();
16
    /**
17
     * Each test is run twice: once using etag/If-None-Match and once with
18
     * date/If-Modified-Since.  Each test run gets its own URL and randomized
19
     * content and operates independently.
20
     *
21
     * The test steps are run with request_cache.length fetch requests issued
22
     * and their immediate results sanity-checked.  The cache.py server script
23
     * stashes an entry containing any If-None-Match, If-Modified-Since, Pragma,
24
     * and Cache-Control observed headers for each request it receives.  When
25
     * the test fetches have run, this state is retrieved from cache.py and the
26
     * expected_* lists are checked, including their length.
27
     *
28
     * This means that if a request_* fetch is expected to hit the cache and not
29
     * touch the network, then there will be no entry for it in the expect_*
30
     * lists.  AKA (request_cache.length - expected_validation_headers.length)
31
     * should equal the number of cache hits that didn't touch the network.
32
     *
33
     * Test dictionary keys:
34
     * - state: required string that determines whether the Expires response for
35
     *   the fetched document should be set in the future ("fresh") or past
36
     *   ("stale").
37
     * - vary: optional string to be passed to the server for it to quote back
38
     *   in a Vary header on the response to us.
39
     * - cache_control: optional string to be passed to the server for it to
40
     *   quote back in a Cache-Control header on the response to us.
41
     * - redirect: optional string "same-origin" or "cross-origin".  If
42
     *   provided, the server will issue an absolute redirect to the script on
43
     *   the same or a different origin, as appropriate.  The redirected
44
     *   location is the script with the redirect parameter removed, so the
45
     *   content/state/etc. will be as if you hadn't specified a redirect.
46
     * - request_cache: required array of cache modes to use (via `cache`).
47
     * - request_headers: optional array of explicit fetch `headers` arguments.
48
     *   If provided, the server will log an empty dictionary for each request
49
     *   instead of the request headers it would normally log.
50
     * - response: optional array of specialized response handling.  Right now,
51
     *   "error" array entries indicate a network error response is expected
52
     *   which will reject with a TypeError.
53
     * - expected_validation_headers: required boolean array indicating whether
54
     *   the server should have seen an If-None-Match/If-Modified-Since header
55
     *   in the request.
56
     * - expected_no_cache_headers: required boolean array indicating whether
57
     *   the server should have seen Pragma/Cache-control:no-cache headers in
58
     *   the request.
59
     * - expected_max_age_headers: optional boolean array indicating whether
60
     *   the server should have seen a Cache-Control:max-age=0 header in the
61
     *   request.
62
     */
63
    var tests = [
64
      {
65
        name: 'RequestCache "default" mode checks the cache for previously cached content and goes to the network for stale responses',
66
        state: "stale",
67
        request_cache: ["default", "default"],
68
        expected_validation_headers: [false, true],
69
        expected_no_cache_headers: [false, false],
70
      },
71
      {
72
        name: 'RequestCache "default" mode checks the cache for previously cached content and avoids going to the network if a fresh response exists',
73
        state: "fresh",
74
        request_cache: ["default", "default"],
75
        expected_validation_headers: [false],
76
        expected_no_cache_headers: [false],
77
      },
78
      {
79
        name: 'RequestCache "no-cache" mode revalidates stale responses found in the cache',
80
        state: "stale",
81
        request_cache: ["default", "no-cache"],
82
        expected_validation_headers: [false, true],
83
        expected_no_cache_headers: [false, false],
84
        expected_max_age_headers: [false, true],
85
      },
86
      {
87
        name: 'RequestCache "no-cache" mode revalidates fresh responses found in the cache',
88
        state: "fresh",
89
        request_cache: ["default", "no-cache"],
90
        expected_validation_headers: [false, true],
91
        expected_no_cache_headers: [false, false],
92
        expected_max_age_headers: [false, true],
93
      },
94
      {
95
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for stale responses',
96
        state: "stale",
97
        request_cache: ["default", "force-cache"],
98
        expected_validation_headers: [false],
99
        expected_no_cache_headers: [false],
100
      },
101
      {
102
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and avoid revalidation for fresh responses',
103
        state: "fresh",
104
        request_cache: ["default", "force-cache"],
105
        expected_validation_headers: [false],
106
        expected_no_cache_headers: [false],
107
      },
108
      {
109
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found',
110
        state: "stale",
111
        request_cache: ["force-cache"],
112
        expected_validation_headers: [false],
113
        expected_no_cache_headers: [false],
114
      },
115
      {
116
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response is not found',
117
        state: "fresh",
118
        request_cache: ["force-cache"],
119
        expected_validation_headers: [false],
120
        expected_no_cache_headers: [false],
121
      },
122
      {
123
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary',
124
        state: "stale",
125
        vary: "*",
126
        request_cache: ["default", "force-cache"],
127
        expected_validation_headers: [false, true],
128
        expected_no_cache_headers: [false, false],
129
      },
130
      {
131
        name: 'RequestCache "force-cache" mode checks the cache for previously cached content and goes to the network if a cached response would vary',
132
        state: "fresh",
133
        vary: "*",
134
        request_cache: ["default", "force-cache"],
135
        expected_validation_headers: [false, true],
136
        expected_no_cache_headers: [false, false],
137
      },
138
      {
139
        name: 'RequestCache "force-cache" stores the response in the cache if it goes to the network',
140
        state: "stale",
141
        request_cache: ["force-cache", "default"],
142
        expected_validation_headers: [false, true],
143
        expected_no_cache_headers: [false, false],
144
      },
145
      {
146
        name: 'RequestCache "force-cache" stores the response in the cache if it goes to the network',
147
        state: "fresh",
148
        request_cache: ["force-cache", "default"],
149
        expected_validation_headers: [false],
150
        expected_no_cache_headers: [false],
151
      },
152
      {
153
        name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses',
154
        state: "stale",
155
        request_cache: ["default", "only-if-cached"],
156
        expected_validation_headers: [false],
157
        expected_no_cache_headers: [false]
158
      },
159
      {
160
        name: 'RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses',
161
        state: "fresh",
162
        request_cache: ["default", "only-if-cached"],
163
        expected_validation_headers: [false],
164
        expected_no_cache_headers: [false]
165
      },
166
      {
167
        name: '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',
168
        state: "fresh",
169
        request_cache: ["only-if-cached"],
170
        response: ["error"],
171
        expected_validation_headers: [],
172
        expected_no_cache_headers: []
173
      },
174
      {
175
        name: 'RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content',
176
        state: "fresh",
177
        request_cache: ["default", "only-if-cached"],
178
        redirect: "same-origin",
179
        expected_validation_headers: [false, false],
180
        expected_no_cache_headers: [false, false],
181
      },
182
      {
183
        name: 'RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content',
184
        state: "stale",
185
        request_cache: ["default", "only-if-cached"],
186
        redirect: "same-origin",
187
        expected_validation_headers: [false, false],
188
        expected_no_cache_headers: [false, false],
189
      },
190
      {
191
        name: 'RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects',
192
        state: "fresh",
193
        request_cache: ["default", "only-if-cached"],
194
        redirect: "cross-origin",
195
        response: [null, "error"],
196
        expected_validation_headers: [false, false],
197
        expected_no_cache_headers: [false, false],
198
      },
199
      {
200
        name: 'RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects',
201
        state: "stale",
202
        request_cache: ["default", "only-if-cached"],
203
        redirect: "cross-origin",
204
        response: [null, "error"],
205
        expected_validation_headers: [false, false],
206
        expected_no_cache_headers: [false, false],
207
      },
208
      {
209
        name: 'RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless',
210
        state: "stale",
211
        request_cache: ["default", "no-store"],
212
        expected_validation_headers: [false, false],
213
        expected_no_cache_headers: [false, true],
214
      },
215
      {
216
        name: 'RequestCache "no-store" mode does not check the cache for previously cached content and goes to the network regardless',
217
        state: "fresh",
218
        request_cache: ["default", "no-store"],
219
        expected_validation_headers: [false, false],
220
        expected_no_cache_headers: [false, true],
221
      },
222
      {
223
        name: 'RequestCache "no-store" mode does not store the response in the cache',
224
        state: "stale",
225
        request_cache: ["no-store", "default"],
226
        expected_validation_headers: [false, false],
227
        expected_no_cache_headers: [true, false],
228
      },
229
      {
230
        name: 'RequestCache "no-store" mode does not store the response in the cache',
231
        state: "fresh",
232
        request_cache: ["no-store", "default"],
233
        expected_validation_headers: [false, false],
234
        expected_no_cache_headers: [true, false],
235
      },
236
      {
237
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
238
        state: "stale",
239
        request_cache: ["default", "default"],
240
        request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
241
        expected_validation_headers: [false, false],
242
        expected_no_cache_headers: [false, true],
243
      },
244
      {
245
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
246
        state: "fresh",
247
        request_cache: ["default", "default"],
248
        request_headers: [{}, {"If-Modified-Since": now.toGMTString()}],
249
        expected_validation_headers: [false, false],
250
        expected_no_cache_headers: [false, true],
251
      },
252
      {
253
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
254
        state: "stale",
255
        request_cache: ["default", "default"],
256
        request_headers: [{"If-Modified-Since": now.toGMTString()}, {}],
257
        expected_validation_headers: [false, false],
258
        expected_no_cache_headers: [true, false],
259
      },
260
      {
261
        name: 'RequestCache "default" mode with an If-Modified-Since header is treated similarly to "no-store"',
262
        state: "fresh",
263
        request_cache: ["default", "default"],
264
        request_headers: [{"If-Modified-Since": now.toGMTString()}, {}],
265
        expected_validation_headers: [false, false],
266
        expected_no_cache_headers: [true, false],
267
      },
268
      {
269
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
270
        state: "stale",
271
        request_cache: ["default", "default"],
272
        request_headers: [{}, {"If-None-Match": '"foo"'}],
273
        expected_validation_headers: [false, false],
274
        expected_no_cache_headers: [false, true],
275
      },
276
      {
277
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
278
        state: "fresh",
279
        request_cache: ["default", "default"],
280
        request_headers: [{}, {"If-None-Match": '"foo"'}],
281
        expected_validation_headers: [false, false],
282
        expected_no_cache_headers: [false, true],
283
      },
284
      {
285
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
286
        state: "stale",
287
        request_cache: ["default", "default"],
288
        request_headers: [{"If-None-Match": '"foo"'}, {}],
289
        expected_validation_headers: [false, false],
290
        expected_no_cache_headers: [true, false],
291
      },
292
      {
293
        name: 'RequestCache "default" mode with an If-None-Match header is treated similarly to "no-store"',
294
        state: "fresh",
295
        request_cache: ["default", "default"],
296
        request_headers: [{"If-None-Match": '"foo"'}, {}],
297
        expected_validation_headers: [false, false],
298
        expected_no_cache_headers: [true, false],
299
      },
300
      {
301
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
302
        state: "stale",
303
        request_cache: ["default", "default"],
304
        request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
305
        expected_validation_headers: [false, false],
306
        expected_no_cache_headers: [false, true],
307
      },
308
      {
309
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
310
        state: "fresh",
311
        request_cache: ["default", "default"],
312
        request_headers: [{}, {"If-Unmodified-Since": now.toGMTString()}],
313
        expected_validation_headers: [false, false],
314
        expected_no_cache_headers: [false, true],
315
      },
316
      {
317
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
318
        state: "stale",
319
        request_cache: ["default", "default"],
320
        request_headers: [{"If-Unmodified-Since": now.toGMTString()}, {}],
321
        expected_validation_headers: [false, false],
322
        expected_no_cache_headers: [true, false],
323
      },
324
      {
325
        name: 'RequestCache "default" mode with an If-Unmodified-Since header is treated similarly to "no-store"',
326
        state: "fresh",
327
        request_cache: ["default", "default"],
328
        request_headers: [{"If-Unmodified-Since": now.toGMTString()}, {}],
329
        expected_validation_headers: [false, false],
330
        expected_no_cache_headers: [true, false],
331
      },
332
      {
333
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
334
        state: "stale",
335
        request_cache: ["default", "default"],
336
        request_headers: [{}, {"If-Match": '"foo"'}],
337
        expected_validation_headers: [false, false],
338
        expected_no_cache_headers: [false, true],
339
      },
340
      {
341
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
342
        state: "fresh",
343
        request_cache: ["default", "default"],
344
        request_headers: [{}, {"If-Match": '"foo"'}],
345
        expected_validation_headers: [false, false],
346
        expected_no_cache_headers: [false, true],
347
      },
348
      {
349
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
350
        state: "stale",
351
        request_cache: ["default", "default"],
352
        request_headers: [{"If-Match": '"foo"'}, {}],
353
        expected_validation_headers: [false, false],
354
        expected_no_cache_headers: [true, false],
355
      },
356
      {
357
        name: 'RequestCache "default" mode with an If-Match header is treated similarly to "no-store"',
358
        state: "fresh",
359
        request_cache: ["default", "default"],
360
        request_headers: [{"If-Match": '"foo"'}, {}],
361
        expected_validation_headers: [false, false],
362
        expected_no_cache_headers: [true, false],
363
      },
364
      {
365
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
366
        state: "stale",
367
        request_cache: ["default", "default"],
368
        request_headers: [{}, {"If-Range": '"foo"'}],
369
        expected_validation_headers: [false, false],
370
        expected_no_cache_headers: [false, true],
371
      },
372
      {
373
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
374
        state: "fresh",
375
        request_cache: ["default", "default"],
376
        request_headers: [{}, {"If-Range": '"foo"'}],
377
        expected_validation_headers: [false, false],
378
        expected_no_cache_headers: [false, true],
379
      },
380
      {
381
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
382
        state: "stale",
383
        request_cache: ["default", "default"],
384
        request_headers: [{"If-Range": '"foo"'}, {}],
385
        expected_validation_headers: [false, false],
386
        expected_no_cache_headers: [true, false],
387
      },
388
      {
389
        name: 'RequestCache "default" mode with an If-Range header is treated similarly to "no-store"',
390
        state: "fresh",
391
        request_cache: ["default", "default"],
392
        request_headers: [{"If-Range": '"foo"'}, {}],
393
        expected_validation_headers: [false, false],
394
        expected_no_cache_headers: [true, false],
395
      },
396
      {
397
        name: 'Responses with the "Cache-Control: no-store" header are not stored in the cache',
398
        state: "stale",
399
        cache_control: "no-store",
400
        request_cache: ["default", "default"],
401
        expected_validation_headers: [false, false],
402
        expected_no_cache_headers: [false, false],
403
      },
404
      {
405
        name: 'Responses with the "Cache-Control: no-store" header are not stored in the cache',
406
        state: "fresh",
407
        cache_control: "no-store",
408
        request_cache: ["default", "default"],
409
        expected_validation_headers: [false, false],
410
        expected_no_cache_headers: [false, false],
411
      },
412
      {
413
        name: 'RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless',
414
        state: "stale",
415
        request_cache: ["default", "reload"],
416
        expected_validation_headers: [false, false],
417
        expected_no_cache_headers: [false, true],
418
      },
419
      {
420
        name: 'RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless',
421
        state: "fresh",
422
        request_cache: ["default", "reload"],
423
        expected_validation_headers: [false, false],
424
        expected_no_cache_headers: [false, true],
425
      },
426
      {
427
        name: 'RequestCache "reload" mode does store the response in the cache',
428
        state: "stale",
429
        request_cache: ["reload", "default"],
430
        expected_validation_headers: [false, true],
431
        expected_no_cache_headers: [true, false],
432
      },
433
      {
434
        name: 'RequestCache "reload" mode does store the response in the cache',
435
        state: "fresh",
436
        request_cache: ["reload", "default"],
437
        expected_validation_headers: [false],
438
        expected_no_cache_headers: [true],
439
      },
440
      {
441
        name: 'RequestCache "reload" mode does store the response in the cache even if a previous response is already stored',
442
        state: "stale",
443
        request_cache: ["default", "reload", "default"],
444
        expected_validation_headers: [false, false, true],
445
        expected_no_cache_headers: [false, true, false],
446
      },
447
      {
448
        name: 'RequestCache "reload" mode does store the response in the cache even if a previous response is already stored',
449
        state: "fresh",
450
        request_cache: ["default", "reload", "default"],
451
        expected_validation_headers: [false, false],
452
        expected_no_cache_headers: [false, true],
453
      },
454
    ];
455
    function base_path() {
456
      return location.pathname.replace(/\/[^\/]*$/, '/');
457
    }
458
    function make_url(uuid, id, value, content, info) {
459
      var dates = {
460
        fresh: new Date(now.getFullYear() + 1, now.getMonth(), now.getDay()).toGMTString(),
461
        stale: new Date(now.getFullYear() - 1, now.getMonth(), now.getDay()).toGMTString(),
462
      };
463
      var vary = "";
464
      if ("vary" in info) {
465
        vary = "&vary=" + info.vary;
466
      }
467
      var cache_control = "";
468
      if ("cache_control" in info) {
469
        cache_control = "&cache_control=" + info.cache_control;
470
      }
471
      var redirect = "";
472
473
      var ignore_request_headers = "";
474
      if ("request_headers" in info) {
475
        // Ignore the request headers that we send since they may be synthesized by the test.
476
        ignore_request_headers = "&ignore";
477
      }
478
      var url_sans_redirect = "resources/cache.py?token=" + uuid +
479
        "&content=" + content +
480
        "&" + id + "=" + value +
481
        "&expires=" + dates[info.state] +
482
        vary + cache_control + ignore_request_headers;
483
      // If there's a redirect, the target is the script without any redirect at
484
      // either the same domain or a different domain.
485
      if ("redirect" in info) {
486
        var host_info = get_host_info();
487
        var origin;
488
        switch (info.redirect) {
489
          case "same-origin":
490
            origin = host_info['HTTP_ORIGIN'];
491
            break;
492
          case "cross-origin":
493
            origin = host_info['HTTP_REMOTE_ORIGIN'];
494
            break;
495
        }
496
        var redirected_url = origin + base_path() + url_sans_redirect;
497
        return url_sans_redirect + "&redirect=" + encodeURIComponent(redirected_url);
498
      } else {
499
        return url_sans_redirect;
500
      }
501
    }
502
    function expected_status(type, identifier, init) {
503
      if (type == "date" &&
504
          init.headers &&
505
          init.headers["If-Modified-Since"] == identifier) {
506
        // The server will respond with a 304 in this case.
507
        return [304, "Not Modified"];
508
      }
509
      return [200, "OK"];
510
    }
511
    function expected_response_text(type, identifier, init, content) {
512
      if (type == "date" &&
513
          init.headers &&
514
          init.headers["If-Modified-Since"] == identifier) {
515
        // The server will respond with a 304 in this case.
516
        return "";
517
      }
518
      return content;
519
    }
520
    function server_state(uuid) {
521
      return fetch("resources/cache.py?querystate&token=" + uuid)
522
        .then(function(response) {
523
          return response.text();
524
        }).then(function(text) {
525
          // null will be returned if the server never received any requests
526
          // for the given uuid.  Normalize that to an empty list consistent
527
          // with our representation.
528
          return JSON.parse(text) || [];
529
        });
530
    }
531
    function make_test(type, info) {
532
      return function(test) {
533
        var uuid = token();
534
        var identifier = (type == "tag" ? Math.random() : now.toGMTString());
535
        var content = Math.random().toString();
536
        var url = make_url(uuid, type, identifier, content, info);
537
        var fetch_functions = [];
538
        for (var i = 0; i < info.request_cache.length; ++i) {
539
          fetch_functions.push(function(idx) {
540
            var init = {cache: info.request_cache[idx]};
541
            if ("request_headers" in info) {
542
              init.headers = info.request_headers[idx];
543
            }
544
            if (init.cache === "only-if-cached") {
545
              // only-if-cached requires we use same-origin mode.
546
              init.mode = "same-origin";
547
            }
548
            return fetch(url, init)
549
              .then(function(response) {
550
                if ("response" in info && info.response[idx] === "error") {
551
                  assert_true(false, "fetch should have been an error");
552
                  return;
553
                }
554
                assert_array_equals([response.status, response.statusText],
555
                                    expected_status(type, identifier, init));
556
                return response.text();
557
              }).then(function(text) {
558
                assert_equals(text, expected_response_text(type, identifier, init, content));
559
              }, function(reason) {
560
                if ("response" in info && info.response[idx] === "error") {
561
                  assert_throws(new TypeError(), function() { throw reason; });
562
                } else {
563
                  throw reason;
564
                }
565
              });
566
          });
567
        }
568
        var i = 0;
569
        function run_next_step() {
570
          if (fetch_functions.length) {
571
            return fetch_functions.shift()(i++)
572
              .then(run_next_step);
573
          } else {
574
            return Promise.resolve();
575
          }
576
        }
577
        return run_next_step()
578
          .then(function() {
579
            // Now, query the server state
580
            return server_state(uuid);
581
          }).then(function(state) {
582
            var expectedState = [];
583
            info.expected_validation_headers.forEach(function (validate) {
584
              if (validate) {
585
                if (type == "tag") {
586
                  expectedState.push({"If-None-Match": '"' + identifier + '"'});
587
                } else {
588
                  expectedState.push({"If-Modified-Since": identifier});
589
                }
590
              } else {
591
                expectedState.push({});
592
              }
593
            });
594
            for (var i = 0; i < info.expected_no_cache_headers.length; ++i) {
595
              if (info.expected_no_cache_headers[i]) {
596
                expectedState[i]["Pragma"] = "no-cache";
597
                expectedState[i]["Cache-Control"] = "no-cache";
598
              }
599
            }
600
            if ("expected_max_age_headers" in info) {
601
              for (var i = 0; i < info.expected_max_age_headers.length; ++i) {
602
                if (info.expected_max_age_headers[i]) {
603
                  expectedState[i]["Cache-Control"] = "max-age=0";
604
                }
605
              }
606
            }
607
            assert_equals(state.length, expectedState.length);
608
            for (var i = 0; i < state.length; ++i) {
609
              for (var header in state[i]) {
610
                assert_equals(state[i][header], expectedState[i][header]);
611
                delete expectedState[i][header];
612
              }
613
              for (var header in expectedState[i]) {
614
                assert_false(header in state[i]);
615
              }
616
            }
617
          });
618
      };
619
    }
620
    tests.forEach(function(info) {
621
      promise_test(make_test("tag", info), info.name + " with Etag and " + info.state + " response");
622
      promise_test(make_test("date", info), info.name + " with date and " + info.state + " response");
623
    });
624
    </script>
625
  </body>
626
</html>
- a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache.js +223 lines
Line 0 a/LayoutTests/imported/w3c/web-platform-tests/fetch/api/request/request-cache.js_sec1
1
/**
2
 * Each test is run twice: once using etag/If-None-Match and once with
3
 * date/If-Modified-Since.  Each test run gets its own URL and randomized
4
 * content and operates independently.
5
 *
6
 * The test steps are run with request_cache.length fetch requests issued
7
 * and their immediate results sanity-checked.  The cache.py server script
8
 * stashes an entry containing any If-None-Match, If-Modified-Since, Pragma,
9
 * and Cache-Control observed headers for each request it receives.  When
10
 * the test fetches have run, this state is retrieved from cache.py and the
11
 * expected_* lists are checked, including their length.
12
 *
13
 * This means that if a request_* fetch is expected to hit the cache and not
14
 * touch the network, then there will be no entry for it in the expect_*
15
 * lists.  AKA (request_cache.length - expected_validation_headers.length)
16
 * should equal the number of cache hits that didn't touch the network.
17
 *
18
 * Test dictionary keys:
19
 * - state: required string that determines whether the Expires response for
20
 *   the fetched document should be set in the future ("fresh") or past
21
 *   ("stale").
22
 * - vary: optional string to be passed to the server for it to quote back
23
 *   in a Vary header on the response to us.
24
 * - cache_control: optional string to be passed to the server for it to
25
 *   quote back in a Cache-Control header on the response to us.
26
 * - redirect: optional string "same-origin" or "cross-origin".  If
27
 *   provided, the server will issue an absolute redirect to the script on
28
 *   the same or a different origin, as appropriate.  The redirected
29
 *   location is the script with the redirect parameter removed, so the
30
 *   content/state/etc. will be as if you hadn't specified a redirect.
31
 * - request_cache: required array of cache modes to use (via `cache`).
32
 * - request_headers: optional array of explicit fetch `headers` arguments.
33
 *   If provided, the server will log an empty dictionary for each request
34
 *   instead of the request headers it would normally log.
35
 * - response: optional array of specialized response handling.  Right now,
36
 *   "error" array entries indicate a network error response is expected
37
 *   which will reject with a TypeError.
38
 * - expected_validation_headers: required boolean array indicating whether
39
 *   the server should have seen an If-None-Match/If-Modified-Since header
40
 *   in the request.
41
 * - expected_no_cache_headers: required boolean array indicating whether
42
 *   the server should have seen Pragma/Cache-control:no-cache headers in
43
 *   the request.
44
 * - expected_max_age_headers: optional boolean array indicating whether
45
 *   the server should have seen a Cache-Control:max-age=0 header in the
46
 *   request.
47
 */
48
49
var now = new Date();
50
51
function base_path() {
52
  return location.pathname.replace(/\/[^\/]*$/, '/');
53
}
54
function make_url(uuid, id, value, content, info) {
55
  var dates = {
56
    fresh: new Date(now.getFullYear() + 1, now.getMonth(), now.getDay()).toGMTString(),
57
    stale: new Date(now.getFullYear() - 1, now.getMonth(), now.getDay()).toGMTString(),
58
  };
59
  var vary = "";
60
  if ("vary" in info) {
61
    vary = "&vary=" + info.vary;
62
  }
63
  var cache_control = "";
64
  if ("cache_control" in info) {
65
    cache_control = "&cache_control=" + info.cache_control;
66
  }
67
  var redirect = "";
68
69
  var ignore_request_headers = "";
70
  if ("request_headers" in info) {
71
    // Ignore the request headers that we send since they may be synthesized by the test.
72
    ignore_request_headers = "&ignore";
73
  }
74
  var url_sans_redirect = "resources/cache.py?token=" + uuid +
75
    "&content=" + content +
76
    "&" + id + "=" + value +
77
    "&expires=" + dates[info.state] +
78
    vary + cache_control + ignore_request_headers;
79
  // If there's a redirect, the target is the script without any redirect at
80
  // either the same domain or a different domain.
81
  if ("redirect" in info) {
82
    var host_info = get_host_info();
83
    var origin;
84
    switch (info.redirect) {
85
      case "same-origin":
86
        origin = host_info['HTTP_ORIGIN'];
87
        break;
88
      case "cross-origin":
89
        origin = host_info['HTTP_REMOTE_ORIGIN'];
90
        break;
91
    }
92
    var redirected_url = origin + base_path() + url_sans_redirect;
93
    return url_sans_redirect + "&redirect=" + encodeURIComponent(redirected_url);
94
  } else {
95
    return url_sans_redirect;
96
  }
97
}
98
function expected_status(type, identifier, init) {
99
  if (type == "date" &&
100
      init.headers &&
101
      init.headers["If-Modified-Since"] == identifier) {
102
    // The server will respond with a 304 in this case.
103
    return [304, "Not Modified"];
104
  }
105
  return [200, "OK"];
106
}
107
function expected_response_text(type, identifier, init, content) {
108
  if (type == "date" &&
109
      init.headers &&
110
      init.headers["If-Modified-Since"] == identifier) {
111
    // The server will respond with a 304 in this case.
112
    return "";
113
  }
114
  return content;
115
}
116
function server_state(uuid) {
117
  return fetch("resources/cache.py?querystate&token=" + uuid)
118
    .then(function(response) {
119
      return response.text();
120
    }).then(function(text) {
121
      // null will be returned if the server never received any requests
122
      // for the given uuid.  Normalize that to an empty list consistent
123
      // with our representation.
124
      return JSON.parse(text) || [];
125
    });
126
}
127
function make_test(type, info) {
128
  return function(test) {
129
    var uuid = token();
130
    var identifier = (type == "tag" ? Math.random() : now.toGMTString());
131
    var content = Math.random().toString();
132
    var url = make_url(uuid, type, identifier, content, info);
133
    var fetch_functions = [];
134
    for (var i = 0; i < info.request_cache.length; ++i) {
135
      fetch_functions.push(function(idx) {
136
        var init = {cache: info.request_cache[idx]};
137
        if ("request_headers" in info) {
138
          init.headers = info.request_headers[idx];
139
        }
140
        if (init.cache === "only-if-cached") {
141
          // only-if-cached requires we use same-origin mode.
142
          init.mode = "same-origin";
143
        }
144
        return fetch(url, init)
145
          .then(function(response) {
146
            if ("response" in info && info.response[idx] === "error") {
147
              assert_true(false, "fetch should have been an error");
148
              return;
149
            }
150
            assert_array_equals([response.status, response.statusText],
151
                                expected_status(type, identifier, init));
152
            return response.text();
153
          }).then(function(text) {
154
            assert_equals(text, expected_response_text(type, identifier, init, content));
155
          }, function(reason) {
156
            if ("response" in info && info.response[idx] === "error") {
157
              assert_throws(new TypeError(), function() { throw reason; });
158
            } else {
159
              throw reason;
160
            }
161
          });
162
      });
163
    }
164
    var i = 0;
165
    function run_next_step() {
166
      if (fetch_functions.length) {
167
        return fetch_functions.shift()(i++)
168
          .then(run_next_step);
169
      } else {
170
        return Promise.resolve();
171
      }
172
    }
173
    return run_next_step()
174
      .then(function() {
175
        // Now, query the server state
176
        return server_state(uuid);
177
      }).then(function(state) {
178
        var expectedState = [];
179
        info.expected_validation_headers.forEach(function (validate) {
180
          if (validate) {
181
            if (type == "tag") {
182
              expectedState.push({"If-None-Match": '"' + identifier + '"'});
183
            } else {
184
              expectedState.push({"If-Modified-Since": identifier});
185
            }
186
          } else {
187
            expectedState.push({});
188
          }
189
        });
190
        for (var i = 0; i < info.expected_no_cache_headers.length; ++i) {
191
          if (info.expected_no_cache_headers[i]) {
192
            expectedState[i]["Pragma"] = "no-cache";
193
            expectedState[i]["Cache-Control"] = "no-cache";
194
          }
195
        }
196
        if ("expected_max_age_headers" in info) {
197
          for (var i = 0; i < info.expected_max_age_headers.length; ++i) {
198
            if (info.expected_max_age_headers[i]) {
199
              expectedState[i]["Cache-Control"] = "max-age=0";
200
            }
201
          }
202
        }
203
        assert_equals(state.length, expectedState.length);
204
        for (var i = 0; i < state.length; ++i) {
205
          for (var header in state[i]) {
206
            assert_equals(state[i][header], expectedState[i][header]);
207
            delete expectedState[i][header];
208
          }
209
          for (var header in expectedState[i]) {
210
            assert_false(header in state[i]);
211
          }
212
        }
213
      });
214
  };
215
}
216
217
function run_tests(tests)
218
{
219
  tests.forEach(function(info) {
220
    promise_test(make_test("tag", info), info.name + " with Etag and " + info.state + " response");
221
    promise_test(make_test("date", info), info.name + " with date and " + info.state + " response");
222
  });
223
}
- a/LayoutTests/platform/ios-simulator/TestExpectations -1 / +2 lines
Lines 2520-2526 webkit.org/b/157592 fast/images/composited-animated-gif-outside-viewport.html [ a/LayoutTests/platform/ios-simulator/TestExpectations_sec1
2520
2520
2521
webkit.org/b/156561 perf/rel-list-remove.html [ Pass Timeout Failure ]
2521
webkit.org/b/156561 perf/rel-list-remove.html [ Pass Timeout Failure ]
2522
2522
2523
webkit.org/b/159683 imported/w3c/web-platform-tests/fetch/api/request/request-cache.html [ Pass Failure ]
2523
webkit.org/b/163332 imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload.html [ Pass Failure ]
2524
webkit.org/b/163332 imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html [ Pass Failure ]
2524
2525
2525
webkit.org/b/158640 imported/blink/storage/indexeddb/blob-valid-after-deletion.html [ Pass Failure ]
2526
webkit.org/b/158640 imported/blink/storage/indexeddb/blob-valid-after-deletion.html [ Pass Failure ]
2526
2527
- a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached-expected.txt +16 lines
Line 0 a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached-expected.txt_sec1
1
2
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with Etag and stale response 
3
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for stale responses with date and stale response 
4
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with Etag and fresh response 
5
PASS RequestCache "only-if-cached" mode checks the cache for previously cached content and avoids revalidation for fresh responses with date and fresh response 
6
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 
7
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 
8
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"
9
FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and fresh response promise_test: Unhandled rejection with value: object "TypeError: Type error"
10
FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with Etag and stale response promise_test: Unhandled rejection with value: object "TypeError: Type error"
11
FAIL RequestCache "only-if-cached" (with "same-origin") uses cached same-origin redirects to same-origin content with date and stale response promise_test: Unhandled rejection with value: object "TypeError: Type error"
12
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and fresh response 
13
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and fresh response 
14
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with Etag and stale response 
15
PASS RequestCache "only-if-cached" (with "same-origin") does not follow redirects across origins and rejects with date and stale response 
16
- a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload-expected.txt +14 lines
Line 0 a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload-expected.txt_sec1
1
2
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and stale response 
3
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and stale response 
4
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with Etag and fresh response 
5
PASS RequestCache "reload" mode does not check the cache for previously cached content and goes to the network regardless with date and fresh response 
6
PASS RequestCache "reload" mode does store the response in the cache with Etag and stale response 
7
PASS RequestCache "reload" mode does store the response in the cache with date and stale response 
8
FAIL RequestCache "reload" mode does store the response in the cache with Etag and fresh response assert_equals: expected 1 but got 2
9
FAIL RequestCache "reload" mode does store the response in the cache with date and fresh response assert_equals: expected 1 but got 2
10
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and stale response 
11
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and stale response 
12
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with Etag and fresh response 
13
PASS RequestCache "reload" mode does store the response in the cache even if a previous response is already stored with date and fresh response 
14
- a/LayoutTests/platform/win/TestExpectations -1 / +2 lines
Lines 3494-3500 imported/w3c/web-platform-tests/fetch/api/credentials/cookies.html [ Failure ] a/LayoutTests/platform/win/TestExpectations_sec1
3494
imported/w3c/web-platform-tests/fetch/api/credentials/cookies-worker.html [ Failure ]
3494
imported/w3c/web-platform-tests/fetch/api/credentials/cookies-worker.html [ Failure ]
3495
imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.html [ Failure ]
3495
imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method.html [ Failure ]
3496
imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker.html [ Failure ]
3496
imported/w3c/web-platform-tests/fetch/api/redirect/redirect-method-worker.html [ Failure ]
3497
imported/w3c/web-platform-tests/fetch/api/request/request-cache.html [ Failure ]
3497
imported/w3c/web-platform-tests/fetch/api/request/request-cache-reload.html [ Failure ]
3498
imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html [ Failure ]
3498
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/unload/007.html [ Failure ]
3499
imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/unload/007.html [ Failure ]
3499
imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_1.html [ Failure ]
3500
imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_forward_1.html [ Failure ]
3500
imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_no_argument.html [ Failure ]
3501
imported/w3c/web-platform-tests/html/browsers/history/the-history-interface/history_go_no_argument.html [ Failure ]
- a/LayoutTests/platform/wk2/TestExpectations -1 / +1 lines
Lines 685-691 fast/images/gif-loop-count.html [ Pass ] a/LayoutTests/platform/wk2/TestExpectations_sec1
685
http/tests/misc/will-send-request-with-client-provided-http-body.html [ Pass ]
685
http/tests/misc/will-send-request-with-client-provided-http-body.html [ Pass ]
686
686
687
# bug 162281
687
# bug 162281
688
imported/w3c/web-platform-tests/fetch/api/request/request-cache.html [ Skip ]
688
imported/w3c/web-platform-tests/fetch/api/request/request-cache-only-if-cached.html [ Failure ]
689
689
690
### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
690
### END OF (5) Progressions, expected successes that are expected failures in WebKit1.
691
########################################
691
########################################

Return to Bug 163332