+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.
--- /dev/null
+Test that subresources can be loaded if manifest is not available. Should say SUCCESS.
+
+SUCCESS
+
--- /dev/null
+<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>
--- /dev/null
+SUCCESS: No crash.
--- /dev/null
+<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>
--- /dev/null
+<?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');
+}
+?>
+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.
}
void ApplicationCacheGroup::stopLoading()
-{
+{
if (m_manifestHandle) {
ASSERT(!m_currentHandle);
- ASSERT(!m_cacheBeingUpdated);
m_manifestHandle->setClient(0);
m_manifestHandle->cancel();
// 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