WebCore:
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2008 22:44:49 +0000 (22:44 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 May 2008 22:44:49 +0000 (22:44 +0000)
2008-05-14  Anders Carlsson  <andersca@apple.com>

        Reviewed by Adam.

        Don't try to store the resource data if it's empty.

        * loader/appcache/ApplicationCacheStorage.cpp:
        (WebCore::ApplicationCacheStorage::store):

LayoutTests:

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

        Reviewed by Adam.

        Add test where a manifest references an empty file.

        * http/tests/appcache/manifest-with-empty-file.html: Added.
        * http/tests/appcache/resources/empty.txt: Added.
        * http/tests/appcache/resources/manifest-with-empty-file.manifest: Added.

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

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

index bbad52e..6752e98 100644 (file)
@@ -1,3 +1,13 @@
+2008-05-14  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam.
+
+        Add test where a manifest references an empty file.
+        
+        * http/tests/appcache/manifest-with-empty-file.html: Added.
+        * http/tests/appcache/resources/empty.txt: Added.
+        * http/tests/appcache/resources/manifest-with-empty-file.manifest: Added.
+
 2008-05-14  David Kilzer  <ddkilzer@apple.com>
 
         REGRESSION (r26474): WebKit fails jQuery test 64 core module: text(String) subtest 1 Check escaped text (createTextNode)
diff --git a/LayoutTests/http/tests/appcache/manifest-with-empty-file.html b/LayoutTests/http/tests/appcache/manifest-with-empty-file.html
new file mode 100644 (file)
index 0000000..b9ae051
--- /dev/null
@@ -0,0 +1,21 @@
+<html manifest="resources/manifest-with-empty-file.manifest">
+<div>This tests that a manifest that contains an empty file will not crash the browser.</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.txt b/LayoutTests/http/tests/appcache/resources/empty.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/LayoutTests/http/tests/appcache/resources/manifest-with-empty-file.manifest b/LayoutTests/http/tests/appcache/resources/manifest-with-empty-file.manifest
new file mode 100644 (file)
index 0000000..aab054b
--- /dev/null
@@ -0,0 +1,2 @@
+CACHE MANIFEST
+empty.txt
index 4e7f2ce..f29ed30 100644 (file)
@@ -1,3 +1,12 @@
+2008-05-14  Anders Carlsson  <andersca@apple.com>
+
+        Reviewed by Adam.
+
+        Don't try to store the resource data if it's empty.
+        
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::store):
+
 2008-05-14  Adam Roben  <aroben@apple.com>
 
         Windows build fix
index 0462a81..730ebdb 100644 (file)
@@ -354,7 +354,8 @@ bool ApplicationCacheStorage::store(ApplicationCacheResource* resource, unsigned
     if (dataStatement.prepare() != SQLResultOk)
         return false;
     
-    dataStatement.bindBlob(1, resource->data()->data(), resource->data()->size());
+    if (resource->data()->size())
+        dataStatement.bindBlob(1, resource->data()->data(), resource->data()->size());
     
     if (!dataStatement.executeCommand())
         return false;