LayoutTests:
authorbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2007 17:52:44 +0000 (17:52 +0000)
committerbeidson <beidson@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2007 17:52:44 +0000 (17:52 +0000)
        Reviewed by Brady

        - pixel test for http://bugs.webkit.org/show_bug.cgi?id=13759
          REGRESSION (r20182-r20184): Incorrect rendering of multipart images

        Created http/tests/multipart and moved the existing multipart test there.

        * http/tests/misc/multipart-expected.txt: Removed.
        * http/tests/misc/multipart.html: Removed.
        * http/tests/misc/resources/1x1-blue.png: Removed.
        * http/tests/misc/resources/multipart.php: Removed.
        * http/tests/multipart/invalid-image-data-expected.checksum: Added.
        * http/tests/multipart/invalid-image-data-expected.png: Added.
        * http/tests/multipart/invalid-image-data-expected.txt: Added.
        * http/tests/multipart/invalid-image-data.html: Added.
        * http/tests/multipart/resources/2x2-green.png: Added. Shared by both
        multipart tests.
        * http/tests/multipart/resources/abe.png: Added.
        * http/tests/multipart/resources/multipart.php: Added. Shared by both
        multipart tests.
        * http/tests/multipart/stop-crash.html: Renamed from misc/multipart.html.

WebCore:

        Reviewed by Brady

        - fix http://bugs.webkit.org/show_bug.cgi?id=13759
          REGRESSION (r20182-r20184): Incorrect rendering of multipart images

        Test: http/tests/multipart/invalid-image-data.html

        * loader/loader.cpp:
        (WebCore::Loader::didReceiveData): Make a copy of the current part's data
        instead of using the resource data, because the latter is going to be
        overwritten by the new part being received.

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/misc/resources/1x1-blue.png [deleted file]
LayoutTests/http/tests/misc/resources/multipart.php [deleted file]
LayoutTests/http/tests/multipart/invalid-image-data-expected.checksum [new file with mode: 0644]
LayoutTests/http/tests/multipart/invalid-image-data-expected.png [new file with mode: 0644]
LayoutTests/http/tests/multipart/invalid-image-data-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/multipart/invalid-image-data.html [new file with mode: 0644]
LayoutTests/http/tests/multipart/resources/2x2-green.png [new file with mode: 0644]
LayoutTests/http/tests/multipart/resources/abe.png [new file with mode: 0644]
LayoutTests/http/tests/multipart/resources/multipart.php [new file with mode: 0644]
LayoutTests/http/tests/multipart/stop-crash-expected.txt [moved from LayoutTests/http/tests/misc/multipart-expected.txt with 100% similarity]
LayoutTests/http/tests/multipart/stop-crash.html [moved from LayoutTests/http/tests/misc/multipart.html with 79% similarity]
WebCore/ChangeLog
WebCore/loader/loader.cpp

index 5febc59..0657985 100644 (file)
@@ -1,3 +1,27 @@
+2007-05-17  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Brady
+
+        - pixel test for http://bugs.webkit.org/show_bug.cgi?id=13759
+          REGRESSION (r20182-r20184): Incorrect rendering of multipart images
+
+        Created http/tests/multipart and moved the existing multipart test there.
+
+        * http/tests/misc/multipart-expected.txt: Removed.
+        * http/tests/misc/multipart.html: Removed.
+        * http/tests/misc/resources/1x1-blue.png: Removed.
+        * http/tests/misc/resources/multipart.php: Removed.
+        * http/tests/multipart/invalid-image-data-expected.checksum: Added.
+        * http/tests/multipart/invalid-image-data-expected.png: Added.
+        * http/tests/multipart/invalid-image-data-expected.txt: Added.
+        * http/tests/multipart/invalid-image-data.html: Added.
+        * http/tests/multipart/resources/2x2-green.png: Added. Shared by both
+        multipart tests.
+        * http/tests/multipart/resources/abe.png: Added.
+        * http/tests/multipart/resources/multipart.php: Added. Shared by both
+        multipart tests.
+        * http/tests/multipart/stop-crash.html: Renamed from misc/multipart.html.
+
 2007-05-17  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by harrison
diff --git a/LayoutTests/http/tests/misc/resources/1x1-blue.png b/LayoutTests/http/tests/misc/resources/1x1-blue.png
deleted file mode 100644 (file)
index c4d0639..0000000
Binary files a/LayoutTests/http/tests/misc/resources/1x1-blue.png and /dev/null differ
diff --git a/LayoutTests/http/tests/misc/resources/multipart.php b/LayoutTests/http/tests/misc/resources/multipart.php
deleted file mode 100644 (file)
index dce2799..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-    $boundary = "cutHere";
-
-    function sendPart($data)
-    {
-        global $boundary;
-
-        echo("Content-Type: image/png\r\n\r\n");
-        echo($data);
-        echo("--$boundary\r\n");
-        flush();
-    }
-
-    $blue = file_get_contents("1x1-blue.png");
-
-    header("Content-Type: multipart/x-mixed-replace; boundary=$boundary");
-
-    echo("--$boundary\r\n");
-    sendPart($blue);
-    sendPart($blue);
-    sleep(10);
-?>
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-expected.checksum b/LayoutTests/http/tests/multipart/invalid-image-data-expected.checksum
new file mode 100644 (file)
index 0000000..6ede876
--- /dev/null
@@ -0,0 +1 @@
+a501b3b6dcb0a994e9980b3158e4948c
\ No newline at end of file
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-expected.png b/LayoutTests/http/tests/multipart/invalid-image-data-expected.png
new file mode 100644 (file)
index 0000000..24de6b7
Binary files /dev/null and b/LayoutTests/http/tests/multipart/invalid-image-data-expected.png differ
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data-expected.txt b/LayoutTests/http/tests/multipart/invalid-image-data-expected.txt
new file mode 100644 (file)
index 0000000..ead1801
--- /dev/null
@@ -0,0 +1,26 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 53x18
+          text run at (0,0) width 53: "Test for "
+        RenderInline {I} at (0,0) size 776x36
+          RenderInline {A} at (0,0) size 301x18 [color=#0000EE]
+            RenderText {#text} at (53,0) size 301x18
+              text run at (53,0) width 301: "http://bugs.webkit.org/show_bug.cgi?id=13759"
+          RenderText {#text} at (354,0) size 776x36
+            text run at (354,0) width 4: " "
+            text run at (358,0) width 418: "REGRESSION (r20182-r20184): Incorrect rendering of multipart"
+            text run at (0,18) width 45: "images"
+        RenderText {#text} at (45,18) size 4x18
+          text run at (45,18) width 4: "."
+      RenderBlock {P} at (0,52) size 784x18
+        RenderText {#text} at (0,0) size 285x18
+          text run at (0,0) width 285: "There should be a bright green square below."
+      RenderBlock (anonymous) at (0,86) size 784x100
+        RenderImage {IMG} at (0,0) size 100x100
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
+        RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/http/tests/multipart/invalid-image-data.html b/LayoutTests/http/tests/multipart/invalid-image-data.html
new file mode 100644 (file)
index 0000000..9cedd1a
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<head>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.waitUntilDone();
+
+        function loadedFirstPart()
+        {
+            if (window.layoutTestController)
+                setTimeout("layoutTestController.notifyDone()", 200);
+        }
+    </script>
+</head>
+<body>
+    <p>
+        Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=13759">http://bugs.webkit.org/show_bug.cgi?id=13759</a>
+        REGRESSION (r20182-r20184): Incorrect rendering of multipart images</i>.
+    </p>
+    <p>
+        There should be a bright green square below.
+    </p>
+    <img width="100" height="100" src="resources/multipart.php?interval=0&img1=2x2-green.png&img2=abe.png" onload="loadedFirstPart()">
+</body>
+</html>
diff --git a/LayoutTests/http/tests/multipart/resources/2x2-green.png b/LayoutTests/http/tests/multipart/resources/2x2-green.png
new file mode 100644 (file)
index 0000000..7e09e37
Binary files /dev/null and b/LayoutTests/http/tests/multipart/resources/2x2-green.png differ
diff --git a/LayoutTests/http/tests/multipart/resources/abe.png b/LayoutTests/http/tests/multipart/resources/abe.png
new file mode 100644 (file)
index 0000000..c932536
Binary files /dev/null and b/LayoutTests/http/tests/multipart/resources/abe.png differ
diff --git a/LayoutTests/http/tests/multipart/resources/multipart.php b/LayoutTests/http/tests/multipart/resources/multipart.php
new file mode 100644 (file)
index 0000000..6e407e5
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+    $boundary = "cutHere";
+
+    function sendPart($data)
+    {
+        global $boundary;
+
+        echo("Content-Type: image/png\r\n\r\n");
+        echo($data);
+        echo("--$boundary\r\n");
+        flush();
+    }
+
+    $i = 1;
+    while ($img = $_GET['img' . $i]) {
+        $images[$i] = file_get_contents($img);
+        $i++;
+    }
+
+    if (isset($_GET['interval']))
+        $interval = $_GET['interval'] * 1000000;
+    else
+        $interval = 1000000;
+
+    header("Content-Type: multipart/x-mixed-replace; boundary=$boundary");
+
+    echo("--$boundary\r\n");
+
+    do {
+        for ($k = 1; $k < $i; $k++) {
+            sendPart($images[$k]);
+            usleep($interval);
+        }
+    } while ($_GET['loop']);
+
+    if (isset($_GET['wait']))
+        usleep($_GET['wait'] * 1000000);
+?>
@@ -18,6 +18,6 @@
     <p>
         If WebKit does not assert or crash after the test, then it passed.
     </p>
-    <img width=24 height=24 src="resources/multipart.php" onload="firstPartLoaded()">
+    <img width=24 height=24 src="resources/multipart.php?interval=0&img1=2x2-green.png&img2=2x2-green.png&wait=10" onload="firstPartLoaded()">
 </body>
 </html>
index 87eb5de..d212ffc 100644 (file)
@@ -1,3 +1,17 @@
+2007-05-17  Mitz Pettel  <mitz@webkit.org>
+
+        Reviewed by Brady
+
+        - fix http://bugs.webkit.org/show_bug.cgi?id=13759
+          REGRESSION (r20182-r20184): Incorrect rendering of multipart images
+
+        Test: http/tests/multipart/invalid-image-data.html
+
+        * loader/loader.cpp:
+        (WebCore::Loader::didReceiveData): Make a copy of the current part's data
+        instead of using the resource data, because the latter is going to be
+        overwritten by the new part being received.
+
 2007-05-17  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Justin.
index 9c5642b..f0f11c5 100644 (file)
@@ -189,10 +189,12 @@ void Loader::didReceiveData(SubresourceLoader* loader, const char* data, int siz
     CachedResource* object = request->cachedResource();    
 
     // Set the data.
-    if (request->isMultipart())
+    if (request->isMultipart()) {
         // The loader delivers the data in a multipart section all at once, send eof.
-        object->data(loader->resourceData(), true);
-    else if (request->isIncremental())
+        // The resource data will change as the next part is loaded, so we need to make a copy.
+        SharedBuffer* copiedData = new SharedBuffer(data, size);
+        object->data(copiedData, true);
+    } else if (request->isIncremental())
         object->data(loader->resourceData(), false);
 }