2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by Adam.
Make it possible to perform synchronous loads from the application cache.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::shouldLoadResourceFromApplicationCache):
Factor out code from scheduleApplicationCacheLoad in its own method.
(WebCore::DocumentLoader::scheduleApplicationCacheLoad):
Call shouldLoadResourceFromApplicationCache here instead.
* loader/DocumentLoader.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously):
Call shouldLoadResourceFromApplicationCache.
WebKitTools:
2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by Adam.
Add support for testing application caches.
* DumpRenderTree/mac/DumpRenderTree.mm:
(dumpRenderTree):
Empty the cache.
(resetWebViewToConsistentStateBeforeTesting):
Turn on support for the application cache.
LayoutTests:
2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by Adam.
Add simple appcache test.
* http/conf/mime.types:
* http/tests/appcache: Added.
* http/tests/appcache/resources: Added.
* http/tests/appcache/resources/not-in-cache.txt: Added.
* http/tests/appcache/resources/simple.manifest: Added.
* http/tests/appcache/resources/simple.txt: Added.
* http/tests/appcache/simple-expected.txt: Added.
* http/tests/appcache/simple.html: Added.
* platform/gtk/Skipped:
* platform/qt/Skipped:
* platform/win/Skipped:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@33057
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-05-12 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Adam.
+
+ Add simple appcache test.
+
+ * http/conf/mime.types:
+ * http/tests/appcache: Added.
+ * http/tests/appcache/resources: Added.
+ * http/tests/appcache/resources/not-in-cache.txt: Added.
+ * http/tests/appcache/resources/simple.manifest: Added.
+ * http/tests/appcache/resources/simple.txt: Added.
+ * http/tests/appcache/simple-expected.txt: Added.
+ * http/tests/appcache/simple.html: Added.
+ * platform/gtk/Skipped:
+ * platform/qt/Skipped:
+ * platform/win/Skipped:
+
2008-05-09 Sam Weinig <sam@webkit.org>
Reviewed by Mark Rowe.
multipart/report
multipart/signed
multipart/voice-message
+text/cache-manifest manifest
text/calendar ics ifb
text/css css
text/directory
--- /dev/null
+This file is not in the cache and is thus not possible to load.
\ No newline at end of file
--- /dev/null
+CACHE MANIFEST
+simple.txt
--- /dev/null
+Hello, World!
\ No newline at end of file
--- /dev/null
+ALERT: whee cached!
+This tests that the application cache works by loading a simple text file from the cache using XMLHttpRequest.
--- /dev/null
+<html manifest="resources/simple.manifest">
+<script>
+if (window.layoutTestController) {
+ layoutTestController.dumpAsText()
+ layoutTestController.waitUntilDone();
+}
+
+function cached()
+{
+ var hadError = false;
+
+ // Load a resource that does not exist in the cache.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "resources/not-in-cache.txt", false);
+ req.send();
+ } catch (e) {
+ if (e.code == XMLHttpRequestException.NETWORK_ERR)
+ hadError = true;
+ }
+
+ if (!hadError) {
+ document.getElementById('result').innerHTML = "FAILURE: Did not get the right exception"
+ return;
+ }
+
+ // Load a resource that exists in the cache.
+ try {
+ var req = new XMLHttpRequest();
+ req.open("GET", "resources/simple.txt", false);
+ req.send();
+ } catch (e) {
+ document.getElementById('result').innerHTML = "FAILURE: Could not load data from cache"
+ return;
+ }
+
+ if (req.responseText != 'Hello, World!') {
+ document.getElementById('result').innerHTML = "FAILURE: Did not get correct data from cached resource"
+ return;
+ }
+
+ document.getElementById('result').innerHTML = "SUCCESS"
+
+ if (window.layoutTestController)
+ layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+
+</script>
+<div>This tests that the application cache works by first loading a file that does not exist in the cache (to verify that a cache has been associated) and then loads a file that is in the cache</div>
+
+<div id="result">FAILURE</div>
+</html>
# Missing LayoutTestController implementations and database related delegate callback
storage/quota-tracking.html
storage/success-callback.html
+# Application cache
+http/tests/appcache
\ No newline at end of file
http/tests/uri
http/tests/xmlhttprequest
+# Application cache
+http/tests/appcache
+
# Tests that currently fail but perhaps used to work at some point.
editing/selection/skip-non-editable-1.html
editing/selection/skip-non-editable-2.html
# Crashes, probably needs new SQLite
storage/multiple-transactions.html
+
+# Application cache
+http/tests/appcache
+
+2008-05-12 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Adam.
+
+ Make it possible to perform synchronous loads from the application cache.
+
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::shouldLoadResourceFromApplicationCache):
+ Factor out code from scheduleApplicationCacheLoad in its own method.
+
+ (WebCore::DocumentLoader::scheduleApplicationCacheLoad):
+ Call shouldLoadResourceFromApplicationCache here instead.
+
+ * loader/DocumentLoader.h:
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadResourceSynchronously):
+ Call shouldLoadResourceFromApplicationCache.
+
2008-05-12 Dan Bernstein <mitz@apple.com>
Reviewed by Ada Chan and Sam Weinig.
return 0;
}
-bool DocumentLoader::scheduleApplicationCacheLoad(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL)
+bool DocumentLoader::shouldLoadResourceFromApplicationCache(const ResourceRequest& request, ApplicationCacheResource*& resource)
{
- if (!frameLoader()->frame()->settings() || !frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled())
- return false;
-
- if (request.url() != originalURL)
- return false;
-
ApplicationCache* cache = topLevelApplicationCache();
if (!cache)
return false;
// If the resource is not a HTTP/HTTPS GET, then abort
if (!ApplicationCache::requestIsHTTPOrHTTPSGet(request))
return false;
-
+
if (cache->isURLInOnlineWhitelist(request.url()))
return false;
- ApplicationCacheResource* resource = cache->resourceForURL(request.url());
+ resource = cache->resourceForURL(request.url());
+
+ // Don't load foreign resources.
+ if (resource && (resource->type() & ApplicationCacheResource::Foreign))
+ resource = 0;
+
+ return true;
+}
+
+bool DocumentLoader::scheduleApplicationCacheLoad(ResourceLoader* loader, const ResourceRequest& request, const KURL& originalURL)
+{
+ if (!frameLoader()->frame()->settings() || !frameLoader()->frame()->settings()->offlineWebApplicationCacheEnabled())
+ return false;
+
+ if (request.url() != originalURL)
+ return false;
+
+ ApplicationCacheResource* resource;
+ if (!shouldLoadResourceFromApplicationCache(request, resource))
+ // FIXME: Handle opportunistic caching namespaces
+ return false;
- // FIXME: Handle opportunistic caching namespaces
- if (!resource || (resource->type() & ApplicationCacheResource::Foreign))
- // A null resource means that the load should fail.
- m_pendingSubstituteResources.set(loader, 0);
- else
- m_pendingSubstituteResources.set(loader, resource);
+ m_pendingSubstituteResources.set(loader, resource);
deliverSubstituteResourcesAfterDelay();
return true;
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
bool scheduleApplicationCacheLoad(ResourceLoader*, const ResourceRequest&, const KURL& originalURL);
-
+ bool shouldLoadResourceFromApplicationCache(const ResourceRequest&, ApplicationCacheResource*&);
+
void setCandidateApplicationCacheGroup(ApplicationCacheGroup* group);
ApplicationCacheGroup* candidateApplicationCacheGroup() const { return m_candidateApplicationCacheGroup; }
#include "config.h"
#include "FrameLoader.h"
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+#include "ApplicationCache.h"
+#include "ApplicationCacheResource.h"
+#endif
#include "Archive.h"
#include "ArchiveFactory.h"
#include "CString.h"
if (error.isNull()) {
ASSERT(!newRequest.isNull());
didTellClientAboutLoad(newRequest.url().string());
- ResourceHandle::loadResourceSynchronously(newRequest, error, response, data, m_frame);
+
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ ApplicationCacheResource* resource;
+ if (documentLoader()->shouldLoadResourceFromApplicationCache(newRequest, resource)) {
+ if (resource) {
+ response = resource->response();
+ data.append(resource->data()->data(), resource->data()->size());
+ } else
+ error = cannotShowURLError(newRequest);
+ } else
+#endif
+ ResourceHandle::loadResourceSynchronously(newRequest, error, response, data, m_frame);
}
sendRemainingDelegateMessages(identifier, response, data.size(), error);
+2008-05-12 Anders Carlsson <andersca@apple.com>
+
+ Reviewed by Adam.
+
+ Add support for testing application caches.
+
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (dumpRenderTree):
+ Empty the cache.
+
+ (resetWebViewToConsistentStateBeforeTesting):
+ Turn on support for the application cache.
+
2008-05-09 Mark Rowe <mrowe@apple.com>
Reviewed by Anders Carlsson.
#import <WebKit/DOMExtensions.h>
#import <WebKit/DOMRange.h>
#import <WebKit/WebBackForwardList.h>
+#import <WebKit/WebCache.h>
#import <WebKit/WebCoreStatistics.h>
#import <WebKit/WebDataSourcePrivate.h>
#import <WebKit/WebDatabaseManagerPrivate.h>
[[NSURLCache sharedURLCache] removeAllCachedResponses];
+ [WebCache empty];
+
// <rdar://problem/5222911>
testStringByEvaluatingJavaScriptFromString();
[preferences setPrivateBrowsingEnabled:NO];
[preferences setAuthorAndUserStylesEnabled:YES];
[preferences setJavaScriptCanOpenWindowsAutomatically:YES];
-
+ [preferences setOfflineWebApplicationCacheEnabled:YES];
+
if (persistentUserStyleSheetLocation) {
[preferences setUserStyleSheetLocation:[NSURL URLWithString:(NSString *)(persistentUserStyleSheetLocation.get())]];
[preferences setUserStyleSheetEnabled:YES];