https://bugs.webkit.org/show_bug.cgi?id=130728
Reviewed by Timothy Hatcher.
Source/WebCore:
When replaying a specific Page we don't want to store its cached resources in the
MemoryCache. This patch adds a page setting to prevent the page's resources from
being saved in the MemoryCache.
If Settings::usesMemoryCache() is false, page resources are given the special
SessionID bypassCacheSessionID(). The cached resource loader and memory cache
act as if the memory cache is disabled if the resource has this special session id.
Hook up ReplayController to override the memory cache setting during capture/replay.
Test: http/tests/cache/bypass-memory-cache-after-reload.html
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::requestResource):
(WebCore::CachedResourceLoader::revalidateResource):
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::add):
* page/Page.cpp:
(WebCore::Page::sessionID):
* page/SessionID.h:
(WebCore::SessionID::bypassCacheSessionID):
* page/Settings.cpp:
(WebCore::Settings::Settings):
* page/Settings.h:
(WebCore::Settings::setUsesMemoryCache):
(WebCore::Settings::usesMemoryCache):
* replay/ReplayController.cpp:
(WebCore::ReplayController::setForceDeterministicSettings):
* replay/ReplayController.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setUsesMemoryCache):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:
Source/WebKit2:
* UIProcess/APISession.cpp:
(API::generateID): update the base ID for generating unique sessions.
LayoutTests:
Mac WebKit2 needs different expectations because of resource load timing characteristics
introduced by the interaction of Settings::usesMemoryCache and NetworkProcess.
* http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
* http/tests/cache/bypass-memory-cache-after-reload.html: Added.
* platform/mac-wk2/http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166434
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-03-28 Brian Burg <bburg@apple.com>
+
+ Web Replay: add page-level setting to bypass the MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=130728
+
+ Reviewed by Timothy Hatcher.
+
+ Mac WebKit2 needs different expectations because of resource load timing characteristics
+ introduced by the interaction of Settings::usesMemoryCache and NetworkProcess.
+
+ * http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
+ * http/tests/cache/bypass-memory-cache-after-reload.html: Added.
+ * platform/mac-wk2/http/tests/cache/bypass-memory-cache-after-reload-expected.txt: Added.
+
2014-03-28 Radu Stavila <stavila@adobe.com>
In some situations, partial layouts of floating elements produce incorrect results.
--- /dev/null
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - didFinishLoading
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/random-cached.cgi, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/cache/resources/random-cached.cgi, http status code 200>
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didFinishLoading
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http status code 200>
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - didFinishLoading
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/random-cached.cgi, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/cache/resources/random-cached.cgi, http status code 200>
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didFinishLoading
+FINISHED LOADING
--- /dev/null
+<body>
+<h1></h1>
+<script>
+// Test that a subresource fetched after onload, following a reload, is
+// not cached if we configure the page's settings to bypass the memory cache.
+if (!sessionStorage.lastRandom) {
+ if (window.testRunner && window.internals) {
+ internals.settings.setUsesMemoryCache(false);
+ testRunner.dumpResourceLoadCallbacks();
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+}
+
+function done(result)
+{
+ delete sessionStorage.lastRandom;
+
+ document.body.innerText = result;
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+function scriptLoaded()
+{
+ setTimeout(function()
+ {
+ if (!window.randomNumber)
+ done('FAIL: window.randomNumber not defined!');
+ else if (sessionStorage.lastRandom) {
+ // We don't want to compare the actual random numbers because
+ // the request may or may not be cached by the network stack.
+ done('FINISHED LOADING');
+ } else {
+ sessionStorage.lastRandom = randomNumber;
+ location.reload();
+ }
+ }, 0);
+}
+
+onload = function()
+{
+ setTimeout(function()
+ {
+ var s = document.createElement("script");
+ s.src = "resources/random-cached.cgi";
+ s.onload = scriptLoaded;
+ document.body.appendChild(s);
+ }, 0);
+};
+</script>
+</body>
--- /dev/null
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - didFinishLoading
+http://127.0.0.1:8000/favicon.ico - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/favicon.ico, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/random-cached.cgi, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/favicon.ico - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/favicon.ico, http status code 200>
+http://127.0.0.1:8000/favicon.ico - didFinishLoading
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/cache/resources/random-cached.cgi, http status code 200>
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didFinishLoading
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http status code 200>
+http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html - didFinishLoading
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/cache/resources/random-cached.cgi, main document URL http://127.0.0.1:8000/cache/bypass-memory-cache-after-reload.html, http method GET> redirectResponse (null)
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didReceiveResponse <NSURLResponse http://127.0.0.1:8000/cache/resources/random-cached.cgi, http status code 200>
+http://127.0.0.1:8000/cache/resources/random-cached.cgi - didFinishLoading
+FINISHED LOADING
+2014-03-28 Brian Burg <bburg@apple.com>
+
+ Web Replay: add page-level setting to bypass the MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=130728
+
+ Reviewed by Timothy Hatcher.
+
+ When replaying a specific Page we don't want to store its cached resources in the
+ MemoryCache. This patch adds a page setting to prevent the page's resources from
+ being saved in the MemoryCache.
+
+ If Settings::usesMemoryCache() is false, page resources are given the special
+ SessionID bypassCacheSessionID(). The cached resource loader and memory cache
+ act as if the memory cache is disabled if the resource has this special session id.
+
+ Hook up ReplayController to override the memory cache setting during capture/replay.
+
+ Test: http/tests/cache/bypass-memory-cache-after-reload.html
+
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::CachedResourceLoader::requestResource):
+ (WebCore::CachedResourceLoader::revalidateResource):
+ * loader/cache/MemoryCache.cpp:
+ (WebCore::MemoryCache::add):
+ * page/Page.cpp:
+ (WebCore::Page::sessionID):
+ * page/SessionID.h:
+ (WebCore::SessionID::bypassCacheSessionID):
+ * page/Settings.cpp:
+ (WebCore::Settings::Settings):
+ * page/Settings.h:
+ (WebCore::Settings::setUsesMemoryCache):
+ (WebCore::Settings::usesMemoryCache):
+ * replay/ReplayController.cpp:
+ (WebCore::ReplayController::setForceDeterministicSettings):
+ * replay/ReplayController.h:
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::Backup::Backup):
+ (WebCore::InternalSettings::Backup::restoreTo):
+ (WebCore::InternalSettings::setUsesMemoryCache):
+ * testing/InternalSettings.h:
+ * testing/InternalSettings.idl:
+
2014-03-28 Radu Stavila <stavila@adobe.com>
In some situations, partial layouts of floating elements produce incorrect results.
m_validatedURLs.add(request.resourceRequest().url());
ASSERT(resource->url() == url.string());
- m_documentResources.set(resource->url(), resource);
+
+ if (sessionID() != SessionID::bypassCacheSessionID())
+ m_documentResources.set(resource->url(), resource);
+
return resource;
}
ASSERT(resource->canUseCacheValidator());
ASSERT(!resource->resourceToRevalidate());
ASSERT(resource->sessionID() == sessionID());
+ ASSERT(sessionID() != SessionID::bypassCacheSessionID());
// Copy the URL out of the resource to be revalidated in case it gets deleted by the remove() call below.
String url = resource->url();
if (disabled())
return false;
+ if (resource->sessionID() == SessionID::bypassCacheSessionID())
+ return false;
+
ASSERT(WTF::isMainThread());
CachedResourceMap& resources = getSessionMap(resource->sessionID());
if (settings().privateBrowsingEnabled())
return SessionID::legacyPrivateSessionID();
+ if (!settings().usesMemoryCache())
+ return SessionID::bypassCacheSessionID();
+
return SessionID::defaultSessionID();
}
static SessionID emptySessionID() { return SessionID(0); }
static SessionID defaultSessionID() { return SessionID(1); }
static SessionID legacyPrivateSessionID() { return SessionID(2); }
+ static SessionID bypassCacheSessionID() { return SessionID(3); }
private:
uint64_t m_sessionID;
};
, m_isScriptEnabled(false)
, m_needsAdobeFrameReloadingQuirk(false)
, m_usesPageCache(false)
+ , m_usesMemoryCache(true)
, m_fontRenderingMode(0)
, m_showTiledScrollingIndicator(false)
, m_tiledBackingStoreEnabled(false)
void setUsesPageCache(bool);
bool usesPageCache() const { return m_usesPageCache; }
-
+
+ void setUsesMemoryCache(bool usesMemoryCache) { m_usesMemoryCache = usesMemoryCache; }
+ bool usesMemoryCache() const { return m_usesMemoryCache; }
+
void setFontRenderingMode(FontRenderingMode mode);
FontRenderingMode fontRenderingMode() const;
bool m_isScriptEnabled : 1;
bool m_needsAdobeFrameReloadingQuirk : 1;
bool m_usesPageCache : 1;
+ bool m_usesMemoryCache : 1;
unsigned m_fontRenderingMode : 1;
bool m_showTiledScrollingIndicator : 1;
bool m_tiledBackingStoreEnabled : 1;
ASSERT(shouldForce ^ (m_sessionState == SessionState::Inactive));
if (shouldForce) {
+ m_savedSettings.usesMemoryCache = m_page.settings().usesMemoryCache();
m_savedSettings.usesPageCache = m_page.settings().usesPageCache();
+ m_page.settings().setUsesMemoryCache(false);
m_page.settings().setUsesPageCache(false);
} else {
+ m_page.settings().setUsesMemoryCache(m_savedSettings.usesMemoryCache);
m_page.settings().setUsesPageCache(m_savedSettings.usesPageCache);
}
}
void setForceDeterministicSettings(bool);
struct SavedSettings {
+ bool usesMemoryCache;
bool usesPageCache;
SavedSettings()
- : usesPageCache(false)
+ : usesMemoryCache(true)
+ , usesPageCache(false)
{ }
};
, m_autoscrollForDragAndDropEnabled(settings.autoscrollForDragAndDropEnabled())
, m_pluginReplacementEnabled(RuntimeEnabledFeatures::sharedFeatures().pluginReplacementEnabled())
, m_shouldConvertPositionStyleOnCopy(settings.shouldConvertPositionStyleOnCopy())
+ , m_usesMemoryCache(settings.usesMemoryCache())
{
}
settings.setUseLegacyBackgroundSizeShorthandBehavior(m_useLegacyBackgroundSizeShorthandBehavior);
settings.setAutoscrollForDragAndDropEnabled(m_autoscrollForDragAndDropEnabled);
settings.setShouldConvertPositionStyleOnCopy(m_shouldConvertPositionStyleOnCopy);
+ settings.setUsesMemoryCache(m_usesMemoryCache);
RuntimeEnabledFeatures::sharedFeatures().setPluginReplacementEnabled(m_pluginReplacementEnabled);
}
settings()->setShouldConvertPositionStyleOnCopy(convert);
}
+void InternalSettings::setUsesMemoryCache(bool usesMemoryCache, ExceptionCode& ec)
+{
+ InternalSettingsGuardForSettings();
+ settings()->setUsesMemoryCache(usesMemoryCache);
+}
+
}
bool m_autoscrollForDragAndDropEnabled;
bool m_pluginReplacementEnabled;
bool m_shouldConvertPositionStyleOnCopy;
+ bool m_usesMemoryCache;
};
static PassRefPtr<InternalSettings> create(Page* page)
void setPluginReplacementEnabled(bool);
void setBackgroundShouldExtendBeyondPage(bool hasExtendedBackground, ExceptionCode&);
void setShouldConvertPositionStyleOnCopy(bool convert, ExceptionCode&);
-
+ void setUsesMemoryCache(bool usesMemoryCache, ExceptionCode&);
private:
explicit InternalSettings(Page*);
void setPluginReplacementEnabled(boolean enabled);
[RaisesException] void setBackgroundShouldExtendBeyondPage(boolean hasExtendedBackground);
[RaisesException] void setShouldConvertPositionStyleOnCopy(boolean convert);
+ [RaisesException] void setUsesMemoryCache(boolean usesMemoryCache);
};
+2014-03-28 Brian Burg <bburg@apple.com>
+
+ Web Replay: add page-level setting to bypass the MemoryCache
+ https://bugs.webkit.org/show_bug.cgi?id=130728
+
+ Reviewed by Timothy Hatcher.
+
+ * UIProcess/APISession.cpp:
+ (API::generateID): update the base ID for generating unique sessions.
+
2014-03-28 Cody Krieger <cjk@apple.com>
Add willSubmitForm callback support to WKWebProcessPlugInFormDelegatePrivate.
{
ASSERT(RunLoop::isMain());
- static uint64_t uniqueSessionID = WebCore::SessionID::legacyPrivateSessionID().sessionID();
+ static uint64_t uniqueSessionID = WebCore::SessionID::bypassCacheSessionID().sessionID();
ASSERT_UNUSED(isEphemeral, isEphemeral);
return ++uniqueSessionID;
}