Diff
Modified: trunk/LayoutTests/ChangeLog (198449 => 198450)
--- trunk/LayoutTests/ChangeLog 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/LayoutTests/ChangeLog 2016-03-18 23:23:09 UTC (rev 198450)
@@ -1,3 +1,18 @@
+2016-03-18 Chris Dumez <[email protected]>
+
+ Speculative revalidation requests do not have their HTTP user-agent set
+ https://bugs.webkit.org/show_bug.cgi?id=155620
+ <rdar://problem/24657567>
+
+ Reviewed by Brady Eidson.
+
+ Add layout test coverage.
+
+ * http/tests/cache/disk-cache/speculative-validation/resources/request-headers-script.php: Added.
+ * http/tests/cache/disk-cache/speculative-validation/resources/validation-request-frame.php: Added.
+ * http/tests/cache/disk-cache/speculative-validation/validation-request-expected.txt: Added.
+ * http/tests/cache/disk-cache/speculative-validation/validation-request.html: Added.
+
2016-03-18 Mark Lam <[email protected]>
ES6 spec requires that RegExpPrototype not be a RegExp object.
Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/request-headers-script.php (0 => 198450)
--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/request-headers-script.php (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/request-headers-script.php 2016-03-18 23:23:09 UTC (rev 198450)
@@ -0,0 +1,12 @@
+<?php
+header('Content-Type: text/_javascript_');
+header('Cache-Control: max-age=0');
+header('Etag: 123456789');
+
+?>
+allRequestHeaders = [];
+<?php
+foreach (getallheaders() as $name => $value) {
+ echo "allRequestHeaders['" . $name . "'] = '" . $value . "';";
+}
+?>
Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/validation-request-frame.php (0 => 198450)
--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/validation-request-frame.php (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/resources/validation-request-frame.php 2016-03-18 23:23:09 UTC (rev 198450)
@@ -0,0 +1,10 @@
+<?php
+header('Content-Type: text/html');
+header('Cache-Control: max-age=0');
+header('Etag: 123456789');
+
+?>
+<!DOCTYPE html>
+<body>
+<script src=""
+</body>
Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/validation-request-expected.txt (0 => 198450)
--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/validation-request-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/validation-request-expected.txt 2016-03-18 23:23:09 UTC (rev 198450)
@@ -0,0 +1,11 @@
+Validates HTTP headers of speculative validation requests.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS validationRequestHeader('If-None-Match') is "123456789"
+PASS validationRequestHeader('User-Agent') is initialUserAgent
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/validation-request.html (0 => 198450)
--- trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/validation-request.html (rev 0)
+++ trunk/LayoutTests/http/tests/cache/disk-cache/speculative-validation/validation-request.html 2016-03-18 23:23:09 UTC (rev 198450)
@@ -0,0 +1,41 @@
+<script src=""
+<script>
+description("Validates HTTP headers of speculative validation requests.");
+jsTestIsAsync = true;
+
+state = "warmup";
+
+function validationRequestHeader(headerName)
+{
+ return frames[0].allRequestHeaders[headerName];
+
+}
+
+function frameLoaded()
+{
+ if (state == "warmup") {
+ initialUserAgent = validationRequestHeader('User-Agent');
+ // Navigate frame to 'about:blank' to flush to subresource loads metadata to disk.
+ state = "flushingMetadata";
+ document.getElementById("testFrame").src = ""
+ return;
+ }
+ if (state == "flushingMetadata") {
+ // Navigate frame to its original location again. This time it should speculatively
+ // validate subresources as we have subresource loads metadata in the disk cache.
+ state = "speculativeRevalidation";
+ document.getElementById("testFrame").src = ""
+ return;
+ }
+ if (state == "speculativeRevalidation") {
+ // Validate the HTTP headers of the speculative validation request.
+ shouldBeEqualToString("validationRequestHeader('If-None-Match')", "123456789");
+ shouldBe("validationRequestHeader('User-Agent')", "initialUserAgent");
+ finishJSTest();
+ return;
+ }
+}
+
+</script>
+<iframe id="testFrame" src="" _onload_="frameLoaded()"></iframe>
+<script src=""
Modified: trunk/Source/WebCore/ChangeLog (198449 => 198450)
--- trunk/Source/WebCore/ChangeLog 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/Source/WebCore/ChangeLog 2016-03-18 23:23:09 UTC (rev 198450)
@@ -1,3 +1,17 @@
+2016-03-18 Chris Dumez <[email protected]>
+
+ Speculative revalidation requests do not have their HTTP user-agent set
+ https://bugs.webkit.org/show_bug.cgi?id=155620
+ <rdar://problem/24657567>
+
+ Reviewed by Brady Eidson.
+
+ Export a couple of symbols so they can be used from WebKit2.
+
+ Test: http/tests/cache/disk-cache/speculative-validation/validation-request.html
+
+ * platform/network/ResourceRequestBase.h:
+
2016-03-18 Zhuo Li <[email protected]>
Need to forward declare NSScrollerImpSPI::scrollerLayoutDirection.
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (198449 => 198450)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2016-03-18 23:23:09 UTC (rev 198450)
@@ -107,8 +107,8 @@
void setHTTPOrigin(const String&);
WEBCORE_EXPORT void clearHTTPOrigin();
- String httpUserAgent() const;
- void setHTTPUserAgent(const String&);
+ WEBCORE_EXPORT String httpUserAgent() const;
+ WEBCORE_EXPORT void setHTTPUserAgent(const String&);
void clearHTTPUserAgent();
String httpAccept() const;
Modified: trunk/Source/WebKit2/ChangeLog (198449 => 198450)
--- trunk/Source/WebKit2/ChangeLog 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-18 23:23:09 UTC (rev 198450)
@@ -1,3 +1,33 @@
+2016-03-18 Chris Dumez <[email protected]>
+
+ Speculative revalidation requests do not have their HTTP user-agent set
+ https://bugs.webkit.org/show_bug.cgi?id=155620
+ <rdar://problem/24657567>
+
+ Reviewed by Brady Eidson.
+
+ Speculative revalidation requests do not have their HTTP user-agent set
+ which could lead to different content getting returned by the server.
+
+ To address the problem, we save the original request's 'user-agent' in
+ the disk cache and re-use it later on for speculative validation
+ requests.
+
+ * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+ (WebKit::NetworkCache::constructRevalidationRequest):
+ (WebKit::NetworkCache::SpeculativeLoadManager::revalidateEntry):
+ (WebKit::NetworkCache::SpeculativeLoadManager::preloadEntry):
+ * NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
+ (WebKit::NetworkCache::SubresourceInfo::encode):
+ (WebKit::NetworkCache::SubresourceInfo::decode):
+ (WebKit::NetworkCache::SubresourceInfo::SubresourceInfo):
+ (WebKit::NetworkCache::SubresourceInfo::operator=):
+ (WebKit::NetworkCache::SubresourcesEntry::SubresourcesEntry):
+ (WebKit::NetworkCache::SubresourcesEntry::updateSubresourceLoads):
+ (WebKit::NetworkCache::SubresourcesEntry::decodeStorageRecord): Deleted.
+ * NetworkProcess/cache/NetworkCacheSubresourcesEntry.h:
+ (WebKit::NetworkCache::SubresourceInfo::SubresourceInfo):
+
2016-03-18 Enrica Casucci <[email protected]>
Add id attribute to _WKActivatedElementInfo.
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (198449 => 198450)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp 2016-03-18 23:23:09 UTC (rev 198450)
@@ -84,10 +84,11 @@
return Key(resourceKey.partition(), subresourcesType(), resourceKey.range(), resourceKey.identifier());
}
-static inline ResourceRequest constructRevalidationRequest(const Entry& entry, const URL& firstPartyForCookies)
+static inline ResourceRequest constructRevalidationRequest(const Entry& entry, const SubresourceInfo& subResourceInfo)
{
ResourceRequest revalidationRequest(entry.key().identifier());
- revalidationRequest.setFirstPartyForCookies(firstPartyForCookies);
+ revalidationRequest.setHTTPUserAgent(subResourceInfo.httpUserAgent);
+ revalidationRequest.setFirstPartyForCookies(subResourceInfo.firstPartyForCookies);
#if ENABLE(CACHE_PARTITIONING)
if (entry.key().hasPartition())
revalidationRequest.setCachePartition(entry.key().partition());
@@ -380,7 +381,7 @@
if (!key.range().isEmpty())
return;
- ResourceRequest revalidationRequest = constructRevalidationRequest(*entry, subresourceInfo.firstPartyForCookies);
+ ResourceRequest revalidationRequest = constructRevalidationRequest(*entry, subresourceInfo);
LOG(NetworkCacheSpeculativePreloading, "(NetworkProcess) Speculatively revalidating '%s':", key.identifier().utf8().data());
auto revalidator = std::make_unique<SpeculativeLoad>(frameID, revalidationRequest, WTFMove(entry), [this, key, frameID](std::unique_ptr<Entry> revalidatedEntry) {
@@ -405,8 +406,7 @@
void SpeculativeLoadManager::preloadEntry(const Key& key, const SubresourceInfo& subResourceInfo, const GlobalFrameID& frameID)
{
m_pendingPreloads.add(key, nullptr);
- URLCapture firstPartyForCookies(subResourceInfo.firstPartyForCookies);
- retrieveEntryFromStorage(key, [this, key, firstPartyForCookies, frameID](std::unique_ptr<Entry> entry) {
+ retrieveEntryFromStorage(key, [this, key, subResourceInfo, frameID](std::unique_ptr<Entry> entry) {
m_pendingPreloads.remove(key);
if (satisfyPendingRequests(key, entry.get())) {
@@ -419,7 +419,7 @@
return;
if (entry->needsValidation())
- revalidateEntry(WTFMove(entry), firstPartyForCookies.url(), frameID);
+ revalidateEntry(WTFMove(entry), subResourceInfo, frameID);
else
addPreloadedEntry(WTFMove(entry), frameID, WasRevalidated::No);
});
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp (198449 => 198450)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp 2016-03-18 23:23:09 UTC (rev 198450)
@@ -40,6 +40,7 @@
{
encoder << firstPartyForCookies;
encoder << isTransient;
+ encoder << httpUserAgent;
}
bool SubresourceInfo::decode(Decoder& decoder, SubresourceInfo& info)
@@ -48,9 +49,26 @@
return false;
if (!decoder.decode(info.isTransient))
return false;
+ if (!decoder.decode(info.httpUserAgent))
+ return false;
return true;
}
+SubresourceInfo::SubresourceInfo(const SubresourceInfo& subresourceInfo)
+ : firstPartyForCookies(subresourceInfo.firstPartyForCookies.isolatedCopy())
+ , httpUserAgent(subresourceInfo.httpUserAgent.isolatedCopy())
+ , isTransient(subresourceInfo.isTransient)
+{
+}
+
+SubresourceInfo& SubresourceInfo::operator=(const SubresourceInfo& other)
+{
+ firstPartyForCookies = other.firstPartyForCookies.isolatedCopy();
+ httpUserAgent = other.httpUserAgent.isolatedCopy();
+ isTransient = other.isTransient;
+ return *this;
+}
+
Storage::Record SubresourcesEntry::encodeAsStorageRecord() const
{
Encoder encoder;
@@ -90,7 +108,7 @@
{
ASSERT(m_key.type() == "subresources");
for (auto& subresourceLoad : subresourceLoads)
- m_subresources.add(subresourceLoad->key, SubresourceInfo(subresourceLoad->request.firstPartyForCookies()));
+ m_subresources.add(subresourceLoad->key, SubresourceInfo(subresourceLoad->request));
}
void SubresourcesEntry::updateSubresourceLoads(const Vector<std::unique_ptr<SubresourceLoad>>& subresourceLoads)
@@ -100,7 +118,7 @@
// Mark keys that are common with last load as non-Transient.
for (auto& subresourceLoad : subresourceLoads) {
bool isTransient = !oldSubresources.contains(subresourceLoad->key);
- m_subresources.add(subresourceLoad->key, SubresourceInfo(subresourceLoad->request.firstPartyForCookies(), isTransient));
+ m_subresources.add(subresourceLoad->key, SubresourceInfo(subresourceLoad->request, isTransient));
}
}
Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.h (198449 => 198450)
--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.h 2016-03-18 23:22:52 UTC (rev 198449)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.h 2016-03-18 23:23:09 UTC (rev 198450)
@@ -43,12 +43,19 @@
static bool decode(Decoder&, SubresourceInfo&);
SubresourceInfo() = default;
- SubresourceInfo(const WebCore::URL& firstPartyForCookies, bool isTransient = false)
- : firstPartyForCookies(firstPartyForCookies)
+ SubresourceInfo(const WebCore::ResourceRequest& request, bool isTransient = false)
+ : firstPartyForCookies(request.firstPartyForCookies())
+ , httpUserAgent(request.httpUserAgent())
, isTransient(isTransient)
{ }
+ SubresourceInfo(const SubresourceInfo&);
+ SubresourceInfo(SubresourceInfo&&) = default;
+ SubresourceInfo& operator=(const SubresourceInfo&);
+ SubresourceInfo& operator=(SubresourceInfo&&) = default;
+
WebCore::URL firstPartyForCookies;
+ String httpUserAgent;
bool isTransient { false };
};