[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

ap at apple.com ap at apple.com
Wed Dec 22 14:07:48 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 8fc1c412ddb670e70ac04ad06169022542950ee6
Author: ap at apple.com <ap at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 4 23:12:02 2010 +0000

            Reviewed by Adam Barth.
    
            https://bugs.webkit.org/show_bug.cgi?id=37812
            Assertion failure when appcache/fail-on-update.html is run twice in a row
    
            Test: http/tests/appcache/fail-on-update-2.html
    
            For some reason, I can't reproduce this assertion failure with ToT, but the fixes I made
            previously are still good, and covered by the new test.
    
            * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::selectCache):
            Handle the case when the cache is already obsolete by the time cache selection occurs.
    
            * loader/appcache/ApplicationCacheHost.cpp: (WebCore::ApplicationCacheHost::failedLoadingMainResource):
            It's not true that loading from appcache always succeeds - it can be aborted.
    
            * loader/appcache/ApplicationCacheStorage.cpp: (WebCore::ApplicationCacheStorage::store):
            Calling ensureOriginRecord(group->origin()) can change lastInsertRowID!
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69048 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f25da35..98b6420 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-04  Alexey Proskuryakov  <ap at apple.com>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=37812
+        Assertion failure when appcache/fail-on-update.html is run twice in a row
+
+        * http/tests/appcache/fail-on-update-2-expected.txt: Added.
+        * http/tests/appcache/fail-on-update-2.html: Added.
+        * http/tests/appcache/resources/fail-on-update-2.html: Added.
+        * http/tests/appcache/resources/fail-on-update-2.php: Added.
+
 2010-10-04  Erik Arvidsson  <arv at chromium.org>
 
         Reviewed by James Robinson.
diff --git a/LayoutTests/http/tests/appcache/fail-on-update-expected.txt b/LayoutTests/http/tests/appcache/fail-on-update-2-expected.txt
similarity index 100%
copy from LayoutTests/http/tests/appcache/fail-on-update-expected.txt
copy to LayoutTests/http/tests/appcache/fail-on-update-2-expected.txt
diff --git a/LayoutTests/http/tests/appcache/fail-on-update-2.html b/LayoutTests/http/tests/appcache/fail-on-update-2.html
new file mode 100644
index 0000000..fcbc3dd
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/fail-on-update-2.html
@@ -0,0 +1,64 @@
+<html manifest="resources/fail-on-update-2.php">
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function setManifestDeleted(state)
+{
+    var req = new XMLHttpRequest;
+    req.open("GET", "resources/fail-on-update.php?command=" + (state ? "delete" : "reset"), false);
+    req.send(null);
+}
+
+function test()
+{
+    clearTimeout(timeoutId);
+
+    setManifestDeleted(true);
+    applicationCache.update();
+    
+    // Create two subframes at different times to make hitting the race condition more likely.
+    var ifr = document.createElement("iframe");
+    ifr.setAttribute("src", 'resources/fail-on-update-2.html');
+    document.body.appendChild(ifr);
+
+    setTimeout(function() {
+        var ifr = document.createElement("iframe");
+        ifr.setAttribute("src", 'resources/fail-on-update-2.html');
+        document.body.appendChild(ifr);
+    }, 0);
+}
+
+var subframesLeft = 2;
+function subframeLoaded()
+{
+    if (!--subframesLeft) {
+        document.write('<p>SUCCESS: No crash.</p>');
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    }
+}
+
+function resetManifest()
+{
+    if (applicationCache.status != applicationCache.UNCACHED && applicationCache.status != applicationCache.OBSOLETE) {
+        timeoutId = setTimeout(resetManifest, 100);
+        return;
+    }
+
+    setManifestDeleted(false);
+    location.reload();
+}
+
+applicationCache.addEventListener('noupdate', function() { setTimeout(test, 0) }, false);
+applicationCache.addEventListener('cached', function() { setTimeout(test, 0) }, false);
+
+// If the manifest script happened to be in a wrong state, reset it.
+var timeoutId = setTimeout(resetManifest, 100);
+
+</script>
+<p>Test for a particular incorrect assertion failure.</p>
+
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/fail-on-update-2.html b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.html
new file mode 100644
index 0000000..7e78de7
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.html
@@ -0,0 +1,7 @@
+<html manifest="fail-on-update-2.php">
+<body>
+<script>
+    top.subframeLoaded();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/appcache/resources/fail-on-update-2.php b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.php
new file mode 100644
index 0000000..4e11735
--- /dev/null
+++ b/LayoutTests/http/tests/appcache/resources/fail-on-update-2.php
@@ -0,0 +1,39 @@
+<?php
+require_once '../../resources/portabilityLayer.php';
+
+$tmpFile = sys_get_temp_dir() . "/" . "fail_on_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);
+}
+
+$command = $_GET['command'];
+$state = getState($tmpFile);
+
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+if ($command == "reset") {
+    unlink($tmpFile);
+} else if ($command == "delete") {
+    setState("Deleted", $tmpFile);
+} else if ($state == "Uninitialized") {
+    header("Content-Type: text/cache-manifest");
+    print("CACHE MANIFEST\n");
+    print("fail-on-update-2.html\n");
+    print("NETWORK:\n");
+    print("fail-on-update.php?command=\n");
+} else if ($state == "Deleted") {
+    header('HTTP/1.0 404 Not Found');
+}
+?>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9e892c8..ba51038 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2010-10-04  Alexey Proskuryakov  <ap at apple.com>
+
+        Reviewed by Adam Barth.
+
+        https://bugs.webkit.org/show_bug.cgi?id=37812
+        Assertion failure when appcache/fail-on-update.html is run twice in a row
+
+        Test: http/tests/appcache/fail-on-update-2.html
+
+        For some reason, I can't reproduce this assertion failure with ToT, but the fixes I made
+        previously are still good, and covered by the new test.
+
+        * loader/appcache/ApplicationCacheGroup.cpp: (WebCore::ApplicationCacheGroup::selectCache):
+        Handle the case when the cache is already obsolete by the time cache selection occurs.
+
+        * loader/appcache/ApplicationCacheHost.cpp: (WebCore::ApplicationCacheHost::failedLoadingMainResource):
+        It's not true that loading from appcache always succeeds - it can be aborted.
+
+        * loader/appcache/ApplicationCacheStorage.cpp: (WebCore::ApplicationCacheStorage::store):
+        Calling ensureOriginRecord(group->origin()) can change lastInsertRowID!
+
 2010-10-04  Erik Arvidsson  <arv at chromium.org>
 
         Reviewed by James Robinson.
diff --git a/WebCore/loader/appcache/ApplicationCacheGroup.cpp b/WebCore/loader/appcache/ApplicationCacheGroup.cpp
index c479a37..dc1e661 100644
--- a/WebCore/loader/appcache/ApplicationCacheGroup.cpp
+++ b/WebCore/loader/appcache/ApplicationCacheGroup.cpp
@@ -159,6 +159,9 @@ void ApplicationCacheGroup::selectCache(Frame* frame, const KURL& passedManifest
     
     if (mainResourceCache) {
         if (manifestURL == mainResourceCache->group()->m_manifestURL) {
+            // The cache may have gotten obsoleted after we've loaded from it, but before we parsed the document and saw cache manifest.
+            if (mainResourceCache->group()->isObsolete())
+                return;
             mainResourceCache->group()->associateDocumentLoaderWithCache(documentLoader, mainResourceCache);
             mainResourceCache->group()->update(frame, ApplicationCacheUpdateWithBrowsingContext);
         } else {
diff --git a/WebCore/loader/appcache/ApplicationCacheHost.cpp b/WebCore/loader/appcache/ApplicationCacheHost.cpp
index 0637eba..f613729 100644
--- a/WebCore/loader/appcache/ApplicationCacheHost.cpp
+++ b/WebCore/loader/appcache/ApplicationCacheHost.cpp
@@ -128,7 +128,10 @@ void ApplicationCacheHost::failedLoadingMainResource()
 {
     ApplicationCacheGroup* group = m_candidateApplicationCacheGroup;
     if (!group && m_applicationCache) {
-        ASSERT(!mainResourceApplicationCache()); // If the main resource were loaded from a cache, it wouldn't fail.
+        if (mainResourceApplicationCache()) {
+            // Even when the main resource is being loaded from an application cache, loading can fail if aborted.
+            return;
+        }
         group = m_applicationCache->group();
     }
     
diff --git a/WebCore/loader/appcache/ApplicationCacheStorage.cpp b/WebCore/loader/appcache/ApplicationCacheStorage.cpp
index 5a82d6e..7b20775 100644
--- a/WebCore/loader/appcache/ApplicationCacheStorage.cpp
+++ b/WebCore/loader/appcache/ApplicationCacheStorage.cpp
@@ -659,10 +659,12 @@ bool ApplicationCacheStorage::store(ApplicationCacheGroup* group, GroupStorageID
     if (!executeStatement(statement))
         return false;
 
+    unsigned groupStorageID = static_cast<unsigned>(m_database.lastInsertRowID());
+
     if (!ensureOriginRecord(group->origin()))
         return false;
 
-    group->setStorageID(static_cast<unsigned>(m_database.lastInsertRowID()));
+    group->setStorageID(groupStorageID);
     journal->add(group, 0);
     return true;
 }    

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list