WebCore:
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 May 2008 22:48:57 +0000 (22:48 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 May 2008 22:48:57 +0000 (22:48 +0000)
2008-05-12  Anders Carlsson  <andersca@apple.com>

        Reviewed by Adam.

        Handle empty manifest files without crashing.

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

LayoutTests:

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.

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

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

index be65d87..aa69087 100644 (file)
@@ -1,5 +1,13 @@
 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.
+
+2008-05-12  Anders Carlsson  <andersca@apple.com>
+
         Update the expected result.
         
         * http/tests/appcache/simple-expected.txt:
diff --git a/LayoutTests/http/tests/appcache/empty-manifest-expected.txt b/LayoutTests/http/tests/appcache/empty-manifest-expected.txt
new file mode 100644 (file)
index 0000000..bba93cf
--- /dev/null
@@ -0,0 +1,2 @@
+This tests that the cached event gets sent even if the manifest is empty.
+SUCCESS
diff --git a/LayoutTests/http/tests/appcache/empty-manifest.html b/LayoutTests/http/tests/appcache/empty-manifest.html
new file mode 100644 (file)
index 0000000..67752e6
--- /dev/null
@@ -0,0 +1,23 @@
+<html manifest="resources/empty.manifest">
+
+<div>This tests that the cached event gets sent even if the manifest is empty.</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/empty.manifest b/LayoutTests/http/tests/appcache/resources/empty.manifest
new file mode 100644 (file)
index 0000000..af16a0e
--- /dev/null
@@ -0,0 +1 @@
+CACHE MANIFEST
index 088c9cf..f781b88 100644 (file)
@@ -1,3 +1,12 @@
+2008-05-12  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam.
+
+        Handle empty manifest files without crashing.
+        
+        * loader/appcache/ApplicationCacheGroup.cpp:
+        (WebCore::ApplicationCacheGroup::startLoadingEntry):
+
 2008-05-12  Alp Toker  <alp@nuanti.com>
 
         GTK+ build fix for breakage in r33056. Include limits.h for INT_MAX.
index 4683227..7664c7a 100644 (file)
@@ -547,6 +547,11 @@ void ApplicationCacheGroup::startLoadingEntry()
 {
     ASSERT(m_cacheBeingUpdated);
 
+    if (m_pendingEntries.isEmpty()) {
+        checkIfLoadIsComplete();
+        return;
+    }
+    
     EntryMap::const_iterator it = m_pendingEntries.begin();
 
     // If this is an initial cache attempt, we do not want to fetch any implicit entries,