WebCore:
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2008 00:28:38 +0000 (00:28 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 May 2008 00:28:38 +0000 (00:28 +0000)
2008-05-12  Anders Carlsson  <andersca@apple.com>

        Reviewed by Adam.

        Handle the case when a resource with the same URL as the manifest is listed in the manifest.

        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::addEntry):

LayoutTests:

2008-05-12  Anders Carlsson  <andersca@apple.com>

        Reviewed by Adam.

        Add test with a manifest file that lists itself.

        * http/tests/appcache/manifest-containing-itself-expected.txt: Added.
        * http/tests/appcache/manifest-containing-itself.html: Added.
        * http/tests/appcache/resources/manifest-containing-itself.manifest: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@33067 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/manifest-containing-itself.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/appcache/ApplicationCacheGroup.cpp

index aa69087..df80a50 100644 (file)
@@ -2,6 +2,16 @@
 
         Reviewed by Adam.
 
+        Add test with a manifest file that lists itself.
+        
+        * http/tests/appcache/manifest-containing-itself-expected.txt: Added.
+        * http/tests/appcache/manifest-containing-itself.html: Added.
+        * http/tests/appcache/resources/manifest-containing-itself.manifest: Added.
+
+2008-05-12  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam.
+
         * http/tests/appcache/empty-manifest-expected.txt: Added.
         * http/tests/appcache/empty-manifest.html: Added.
         * http/tests/appcache/resources/empty.manifest: Added.
diff --git a/LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt b/LayoutTests/http/tests/appcache/manifest-containing-itself-expected.txt
new file mode 100644 (file)
index 0000000..77e2506
--- /dev/null
@@ -0,0 +1,2 @@
+This tests that a manifest can contain itself as a resource.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/manifest-containing-itself.html b/LayoutTests/http/tests/appcache/manifest-containing-itself.html
new file mode 100644 (file)
index 0000000..4cad323
--- /dev/null
@@ -0,0 +1,23 @@
+<html manifest="resources/manifest-containing-itself.manifest">
+
+<div>This tests that a manifest can contain itself as a resource.</div>
+<div id="result">FAILURE</div>
+
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText()
+    layoutTestController.waitUntilDone();
+}
+
+function cached()
+{
+    document.getElementById('result').innerHTML = 'SUCCESS';
+    
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+applicationCache.addEventListener('cached', cached, false);
+
+</script>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest b/LayoutTests/http/tests/appcache/resources/manifest-containing-itself.manifest
new file mode 100644 (file)
index 0000000..eb5c126
--- /dev/null
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+manifest-containing-itself.manifest
index 3a056f5..486df1f 100644 (file)
@@ -1,3 +1,12 @@
+2008-05-12  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam.
+
+        Handle the case when a resource with the same URL as the manifest is listed in the manifest.
+
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::addEntry):
+
 2008-05-12  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Dan Bernstein.
index 7664c7a..14bb969 100644 (file)
@@ -583,13 +583,19 @@ void ApplicationCacheGroup::addEntry(const String& url, unsigned type)
 {
     ASSERT(m_cacheBeingUpdated);
     
-    // Don't add the url if we already have an implicit resource in the cache
+    // Don't add the URL if we already have an implicit resource in the cache
     if (ApplicationCacheResource* resource = m_cacheBeingUpdated->resourceForURL(url)) {
         ASSERT(resource->type() & ApplicationCacheResource::Implicit);
     
         resource->addType(type);
         return;
     }
+
+    // Don't add the URL if it's the same as the manifest URL.
+    if (m_manifestResource && m_manifestResource->url() == url) {
+        m_manifestResource->addType(type);
+        return;
+    }
     
     pair<EntryMap::iterator, bool> result = m_pendingEntries.add(url, type);