WebCore:
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2008 04:25:25 +0000 (04:25 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Feb 2008 04:25:25 +0000 (04:25 +0000)
        Reviewed by Geoff.

        Fixed for <rdar://problem/5760530> REGRESSION: Assertion failure in
        Document::removePendingSheet() from r30438

        r30438 added a call to CachedResource::error() from inside
        Loader::didReceiveData() if a CSS file 4xxs. There was an
        assumption in the loader, though, that either error() would be
        called, or didFinishLoading() would be called, so some work is
        duplicated in each. Now that we are calling an error() on files
        that will also make it to didFinishLoading() (since they succeeded
        in the network layer), we need to make sure we do not duplicate the
        work. CachedCSSStyleSheet::error() calls checkNotify, which ends up
        decrementing the document's pending style sheet counter.
        checkNotify() was still getting called, though, through the normal
        didFinishLoading code path, and the counter was being decremented
        twice. Bad!

        * loader/loader.cpp:
        (WebCore::Loader::didFinishLoading):
        (WebCore::Loader::didReceiveData):

LayoutTests:

        Reviewed by Geoff.

        Test for <rdar://problem/5760530> REGRESSION: Assertion failure in
        Document::removePendingSheet() from r30438

        * http/tests/misc/missing-style-sheet-expected.txt: Added.
        * http/tests/misc/missing-style-sheet.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/misc/missing-style-sheet-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/missing-style-sheet.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/loader.cpp

index cf852b4196385257a8b080187fb80df83d6c49ef..bf34e3363c4aea3916b5ae50ba45e7cada50fd91 100644 (file)
@@ -1,3 +1,13 @@
+2008-02-25  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Geoff.
+
+        Test for <rdar://problem/5760530> REGRESSION: Assertion failure in 
+        Document::removePendingSheet() from r30438
+
+        * http/tests/misc/missing-style-sheet-expected.txt: Added.
+        * http/tests/misc/missing-style-sheet.html: Added.
+
 2008-02-25  Brady Eidson  <beidson@apple.com>
 
         Reviewed by T3h Mitz Pettel (Dan Bernstein)
diff --git a/LayoutTests/http/tests/misc/missing-style-sheet-expected.txt b/LayoutTests/http/tests/misc/missing-style-sheet-expected.txt
new file mode 100644 (file)
index 0000000..9952d68
--- /dev/null
@@ -0,0 +1 @@
+This test passes if it does not ASSERT that the document's pending style sheet count is less than 0.
diff --git a/LayoutTests/http/tests/misc/missing-style-sheet.html b/LayoutTests/http/tests/misc/missing-style-sheet.html
new file mode 100644 (file)
index 0000000..7f2cb58
--- /dev/null
@@ -0,0 +1,9 @@
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+
+<link href="/adeleandbethrock.css" rel="stylesheet" type="text/css">
+
+This test passes if it does not ASSERT that the document's pending style sheet count is less than 0.  
\ No newline at end of file
index 8cc371fbf5a445b561adca07687d880a9ccdbc8e..58c17c2e6bb1836b4a461357eb7f3a1e5b233b0d 100644 (file)
@@ -1,3 +1,27 @@
+2008-02-25  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Geoff.
+
+        Fixed for <rdar://problem/5760530> REGRESSION: Assertion failure in 
+        Document::removePendingSheet() from r30438
+
+        r30438 added a call to CachedResource::error() from inside 
+        Loader::didReceiveData() if a CSS file 4xxs. There was an 
+        assumption in the loader, though, that either error() would be 
+        called, or didFinishLoading() would be called, so some work is 
+        duplicated in each. Now that we are calling an error() on files 
+        that will also make it to didFinishLoading() (since they succeeded 
+        in the network layer), we need to make sure we do not duplicate the 
+        work. CachedCSSStyleSheet::error() calls checkNotify, which ends up 
+        decrementing the document's pending style sheet counter. 
+        checkNotify() was still getting called, though, through the normal  
+        didFinishLoading code path, and the counter was being decremented 
+        twice. Bad!
+
+        * loader/loader.cpp:
+        (WebCore::Loader::didFinishLoading):
+        (WebCore::Loader::didReceiveData):
+
 2008-02-25  Mark Rowe  <mrowe@apple.com>
 
         Fix the Gtk, wx and Qt builds.
index 66d2a822b4d0c48f78ea424d986fa414497ded07..49dac0d9b65b021037a608417b8a8df913dc4ada 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
index 7b8a46585d7f2a9e359a29a74834527d6ca8119d..39e6c071e9d291fa12cbdedfb546c17f1c74c237 100644 (file)
@@ -109,10 +109,14 @@ void Loader::didFinishLoading(SubresourceLoader* loader)
 
     CachedResource* object = req->cachedResource();
 
-    docLoader->setLoadInProgress(true);
-    object->data(loader->resourceData(), true);
-    docLoader->setLoadInProgress(false);
-    object->finish();
+    // If we got a 4xx response, we're pretending to have received a network
+    // error, so we can't send the successful data() and finish() callbacks.
+    if (!object->errorOccurred()) {
+        docLoader->setLoadInProgress(true);
+        object->data(loader->resourceData(), true);
+        docLoader->setLoadInProgress(false);
+        object->finish();
+    }
 
     delete req;
 
@@ -198,7 +202,7 @@ void Loader::didReceiveData(SubresourceLoader* loader, const char* data, int siz
         return;
     
     if (object->response().httpStatusCode() / 100 == 4) {
-        // Make sure the 4xx error codes result in an error.
+        // Treat a 4xx response like a network error.
         object->error();
         return;
     }