Reviewed by Darin Adler.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2008 18:16:59 +0000 (18:16 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2008 18:16:59 +0000 (18:16 +0000)
        <rdar://problem/6277060> ASSERTION FAILED: !m_cacheBeingUpdated if the manifest is not available

        Tests: http/tests/appcache/404-manifest.html
               http/tests/appcache/fail-on-update.html

        * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::stopLoading):
        Removed the incorrect assertion.

        * loader/appcache/ApplicationCacheGroup.h: Added an explanation of somewhat nonintuitive
        m_currentHandle handling.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/appcache/404-manifest-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/404-manifest.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/fail-on-update-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/appcache/fail-on-update.html [new file with mode: 0644]
LayoutTests/http/tests/appcache/resources/fail-on-update.php [new file with mode: 0644]
WebCore/ChangeLog
WebCore/loader/appcache/ApplicationCacheGroup.cpp
WebCore/loader/appcache/ApplicationCacheGroup.h

index 87046eb..17cdbc0 100644 (file)
@@ -1,3 +1,18 @@
+2008-12-22  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/6277060> ASSERTION FAILED: !m_cacheBeingUpdated if the manifest is not available
+
+        Cover both the failing case, and its opposite, demonstrating that the assertion couldn't be
+        just negated.
+
+        * http/tests/appcache/404-manifest-expected.txt: Added.
+        * http/tests/appcache/404-manifest.html: Added.
+        * http/tests/appcache/fail-on-update-expected.txt: Added.
+        * http/tests/appcache/fail-on-update.html: Added.
+        * http/tests/appcache/resources/fail-on-update.php: Added.
+
 2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by Alexey Proskuryakov & George Staikos.
diff --git a/LayoutTests/http/tests/appcache/404-manifest-expected.txt b/LayoutTests/http/tests/appcache/404-manifest-expected.txt
new file mode 100644 (file)
index 0000000..b047077
--- /dev/null
@@ -0,0 +1,4 @@
+Test that subresources can be loaded if manifest is not available. Should say SUCCESS.
+
+SUCCESS
+
diff --git a/LayoutTests/http/tests/appcache/404-manifest.html b/LayoutTests/http/tests/appcache/404-manifest.html
new file mode 100644 (file)
index 0000000..f76f4c8
--- /dev/null
@@ -0,0 +1,57 @@
+<html manifest="does-not-exist.manifest">
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText()
+    layoutTestController.waitUntilDone();
+}
+
+function log(message)
+{
+    document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function unexpectedEvent(name)
+{
+    log("FAILURE: Unexpected " + name + " event.");
+}
+
+// This is a cache attempt, so there are no associated browsing contexts, and the events are
+// only dispatched to associated browsing contexts.
+applicationCache.addEventListener('checking', function() { unexpectedEvent("checking") }, false);
+applicationCache.addEventListener('noupdate', function() { unexpectedEvent("noupdate") }, false);
+applicationCache.addEventListener('downloading', function() { unexpectedEvent("downloading") }, false);
+applicationCache.addEventListener('progress', function() { unexpectedEvent("progress") }, false);
+applicationCache.addEventListener('updateready', function() { unexpectedEvent("updateready") }, false);
+applicationCache.addEventListener('cached', function() { unexpectedEvent("cached") }, false);
+applicationCache.addEventListener('obsolete', function() { unexpectedEvent("obsolete") }, false);
+
+function test()
+{
+    if (window.applicationCache.status)
+        log("FAILURE: Cache status is not UNCACHED, " + window.applicationCache.status);
+
+    // The manifest failed to load, so there should be no cache, and subresources should be loaded normally.
+    try {
+        var req = new XMLHttpRequest();
+        req.open("GET", "resources/simple.txt", false);
+        req.send();
+
+        if (req.responseText == 'Hello, World!')
+            log("SUCCESS");
+        else
+            log("FAILURE: Did not get expected response data.");
+    } catch (e) {
+        log("FAILURE: Could not load data.");
+    }
+
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+setTimeout(test, 100);
+
+</script>
+<p>Test that subresources can be loaded if manifest is not available. Should say SUCCESS.</p>
+
+<div id=result></div>
+</html>
diff --git a/LayoutTests/http/tests/appcache/fail-on-update-expected.txt b/LayoutTests/http/tests/appcache/fail-on-update-expected.txt
new file mode 100644 (file)
index 0000000..cd15247
--- /dev/null
@@ -0,0 +1 @@
+SUCCESS: No crash.
diff --git a/LayoutTests/http/tests/appcache/fail-on-update.html b/LayoutTests/http/tests/appcache/fail-on-update.html
new file mode 100644 (file)
index 0000000..b560a3b
--- /dev/null
@@ -0,0 +1,23 @@
+<html manifest="resources/fail-on-update.php">
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function test()
+{
+    applicationCache.update();
+    window.location = 'data:text/html,<p>SUCCESS: No crash.</p>' + 
+        '<script>' +
+            'if (window.layoutTestController) layoutTestController.notifyDone();' +
+        '</scri' + 'pt>';
+}
+
+applicationCache.addEventListener('noupdate', function() { test() }, false);
+applicationCache.addEventListener('cached', function() { test() }, false);
+
+</script>
+<p>Test for a particular incorrect assertion failure.</p>
+
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/fail-on-update.php b/LayoutTests/http/tests/appcache/resources/fail-on-update.php
new file mode 100644 (file)
index 0000000..a85f054
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+require_once '../../xmlhttprequest/resources/portabilityLayer.php';
+
+$tmpFile = ensureTrailingSlash(sys_get_temp_dir()) . "abort_update_state";
+
+function setState($newState, $file)
+{
+    file_put_contents($file, $newState);
+}
+
+function getState($file)
+{
+    if (!file_exists($file)) {
+        return "Uninitialized";
+    }
+    return file_get_contents($file);
+}
+
+$state = getState($tmpFile);
+
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-store, no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+if ($state == "Uninitialized") {
+    setState("ManifestSent", $tmpFile);
+    header("Content-Type: text/cache-manifest");
+    print("CACHE MANIFEST\n");
+} else if ($state == "ManifestSent") {
+    unlink($tmpFile);
+    header('HTTP/1.0 404 Not Found');
+}
+?>
index 419bd6c..87e0214 100644 (file)
@@ -1,3 +1,18 @@
+2008-12-22  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Darin Adler.
+
+        <rdar://problem/6277060> ASSERTION FAILED: !m_cacheBeingUpdated if the manifest is not available
+
+        Tests: http/tests/appcache/404-manifest.html
+               http/tests/appcache/fail-on-update.html
+
+        * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::stopLoading):
+        Removed the incorrect assertion.
+
+        * loader/appcache/ApplicationCacheGroup.h: Added an explanation of somewhat nonintuitive
+        m_currentHandle handling.
+
 2008-12-22  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
         Reviewed by Alexey Proskuryakov & George Staikos.
index ff26767..e37ffaf 100644 (file)
@@ -244,10 +244,9 @@ void ApplicationCacheGroup::failedLoadingMainResource(DocumentLoader* loader)
 }
 
 void ApplicationCacheGroup::stopLoading()
-{    
+{
     if (m_manifestHandle) {
         ASSERT(!m_currentHandle);
-        ASSERT(!m_cacheBeingUpdated);
 
         m_manifestHandle->setClient(0);
         m_manifestHandle->cancel();
index d5b7563..11870b7 100644 (file)
@@ -116,7 +116,8 @@ private:
     // The caches in this cache group.
     HashSet<ApplicationCache*> m_caches;
     
-    // The cache being updated (if any).
+    // The cache being updated (if any). Note that cache updating does not immediately create a new
+    // ApplicationCache object, so this may be null even when status is not Idle.
     RefPtr<ApplicationCache> m_cacheBeingUpdated;
 
     // When a cache group does not yet have a complete cache, this contains the document loaders