Bug 22466: REGRESSION (35867): Many resources missing when saving webarchive...
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Dec 2008 00:53:35 +0000 (00:53 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Dec 2008 00:53:35 +0000 (00:53 +0000)
        <https://bugs.webkit.org/show_bug.cgi?id=22466>
        <rdar://problem/6403593>

        Reviewed by Brady Eidson.

WebCore:

        Test: http/tests/webarchive/test-preload-resources.html

        * loader/archive/cf/LegacyWebArchive.cpp:
        (WebCore::LegacyWebArchive::create): Check the WebCore cache for
        resources if DocumentLoader::subresource() doesn't return them.
        Note that the DocumentLoader::subresource() method returned
        preloaded resources before r35867, but this caused a regression in
        Mail.

WebKitTools:

        * DumpRenderTree/mac/DumpRenderTree.mm:
        (normalizeHTTPResponseHeaderFields): Added.  Normalizes Date, Etag,
        Keep-Alive, Last-Modified and Server header fields to prevent false
        positive test failures.
        (convertWebResourceResponseToDictionary): Call
        normalizeHTTPResponseHeaderFields() to noramlize HTTP response
        header fields.

LayoutTests:

        * http/tests/webarchive/resources/test-preload-resources.css: Added.
        * http/tests/webarchive/test-preload-resources-expected.webarchive: Added.
        * http/tests/webarchive/test-preload-resources.html: Added.
        * platform/qt/Skipped: Added http/tests/webarchive and grouped the
        skipped list of other webarchive tests together.
        * platform/win/Skipped: Added http/tests/webarchive.

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

LayoutTests/ChangeLog
LayoutTests/http/tests/webarchive/resources/test-preload-resources.css [new file with mode: 0644]
LayoutTests/http/tests/webarchive/test-preload-resources-expected.webarchive [new file with mode: 0644]
LayoutTests/http/tests/webarchive/test-preload-resources.html [new file with mode: 0644]
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
WebCore/ChangeLog
WebCore/loader/archive/cf/LegacyWebArchive.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm

index 44a0f45..e99e568 100644 (file)
@@ -1,3 +1,19 @@
+2008-12-01  David Kilzer  <ddkilzer@apple.com>
+
+        Bug 22466: REGRESSION (35867): Many resources missing when saving webarchive of webkit.org
+
+        <https://bugs.webkit.org/show_bug.cgi?id=22466>
+        <rdar://problem/6403593>
+
+        Reviewed by Brady Eidson.
+
+        * http/tests/webarchive/resources/test-preload-resources.css: Added.
+        * http/tests/webarchive/test-preload-resources-expected.webarchive: Added.
+        * http/tests/webarchive/test-preload-resources.html: Added.
+        * platform/qt/Skipped: Added http/tests/webarchive and grouped the
+        skipped list of other webarchive tests together.
+        * platform/win/Skipped: Added http/tests/webarchive.
+
 2008-12-01  Pamela Greene  <pam@chromium.org>
 
         Reviewed by Darin Adler.
 2008-12-01  Pamela Greene  <pam@chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/http/tests/webarchive/resources/test-preload-resources.css b/LayoutTests/http/tests/webarchive/resources/test-preload-resources.css
new file mode 100644 (file)
index 0000000..153df6f
--- /dev/null
@@ -0,0 +1 @@
+/* test-preload-resources.css */
diff --git a/LayoutTests/http/tests/webarchive/test-preload-resources-expected.webarchive b/LayoutTests/http/tests/webarchive/test-preload-resources-expected.webarchive
new file mode 100644 (file)
index 0000000..6520465
--- /dev/null
@@ -0,0 +1,331 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>WebMainResource</key>
+       <dict>
+               <key>WebResourceData</key>
+               <string>&lt;html&gt;&lt;head&gt;
+
+&lt;link rel="stylesheet" type="text/css" href="resources/test-preload-resources.css"&gt;
+&lt;link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?1" title="green"&gt;
+&lt;link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?2" title="blue"&gt;
+&lt;link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?3" title="yellow"&gt;
+&lt;link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?4" title="pink"&gt;
+&lt;link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?5" title="purple"&gt;
+&lt;link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?6" title="gray"&gt;
+
+&lt;script&gt;
+if (window.layoutTestController)
+    layoutTestController.dumpDOMAsWebArchive();
+&lt;/script&gt;
+
+&lt;/head&gt;&lt;body&gt;
+&lt;div&gt;
+Test for &lt;a href="https://bugs.webkit.org/show_bug.cgi?id=22466"&gt;Bug 22466:
+REGRESSION (35867): Many resources missing when saving webarchive of webkit.org&lt;/a&gt;
+&lt;/div&gt;
+&lt;p&gt;Some resources are missing when saving this page as a webarchive.&lt;/p&gt;
+
+&lt;/body&gt;&lt;/html&gt;</string>
+               <key>WebResourceFrameName</key>
+               <string></string>
+               <key>WebResourceMIMEType</key>
+               <string>text/html</string>
+               <key>WebResourceTextEncodingName</key>
+               <string>UTF-8</string>
+               <key>WebResourceURL</key>
+               <string>http://127.0.0.1:8000/webarchive/test-preload-resources.html</string>
+       </dict>
+       <key>WebSubresources</key>
+       <array>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css</string>
+               </dict>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?1</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?1</string>
+               </dict>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?2</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?2</string>
+               </dict>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?3</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?3</string>
+               </dict>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?4</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?4</string>
+               </dict>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?5</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?5</string>
+               </dict>
+               <dict>
+                       <key>WebResourceData</key>
+                       <string>/* test-preload-resources.css */
+</string>
+                       <key>WebResourceMIMEType</key>
+                       <string>text/css</string>
+                       <key>WebResourceResponse</key>
+                       <dict>
+                               <key>MIMEType</key>
+                               <string>text/css</string>
+                               <key>URL</key>
+                               <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?6</string>
+                               <key>allHeaderFields</key>
+                               <dict>
+                                       <key>Accept-Ranges</key>
+                                       <string>bytes</string>
+                                       <key>Connection</key>
+                                       <string>Keep-Alive</string>
+                                       <key>Content-Length</key>
+                                       <string>33</string>
+                                       <key>Content-Type</key>
+                                       <string>text/css</string>
+                                       <key>Date</key>
+                                       <string>Sun, 16 Nov 2008 17:00:00 GMT</string>
+                                       <key>Etag</key>
+                                       <string>"301925-21-45c7d72d3e780"</string>
+                                       <key>Keep-Alive</key>
+                                       <string>timeout=15</string>
+                                       <key>Last-Modified</key>
+                                       <string>Sun, 16 Nov 2008 16:55:00 GMT</string>
+                                       <key>Server</key>
+                                       <string>Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6</string>
+                               </dict>
+                               <key>expectedContentLength</key>
+                               <integer>33</integer>
+                               <key>statusCode</key>
+                               <integer>200</integer>
+                       </dict>
+                       <key>WebResourceURL</key>
+                       <string>http://127.0.0.1:8000/webarchive/resources/test-preload-resources.css?6</string>
+               </dict>
+       </array>
+</dict>
+</plist>
diff --git a/LayoutTests/http/tests/webarchive/test-preload-resources.html b/LayoutTests/http/tests/webarchive/test-preload-resources.html
new file mode 100644 (file)
index 0000000..03afb73
--- /dev/null
@@ -0,0 +1,22 @@
+<html><head>
+
+<link rel="stylesheet" type="text/css" href="resources/test-preload-resources.css">
+<link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?1" title="green">
+<link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?2" title="blue">
+<link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?3" title="yellow">
+<link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?4" title="pink">
+<link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?5" title="purple">
+<link rel="alternate stylesheet" type="text/css" href="resources/test-preload-resources.css?6" title="gray">
+
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpDOMAsWebArchive();
+</script>
+
+</head><body>
+<div>
+Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=22466">Bug 22466:
+REGRESSION (35867): Many resources missing when saving webarchive of webkit.org</a>
+</div>
+<p>Some resources are missing when saving this page as a webarchive.</p>
+</body></html>
index 9c84e43..4ae7a5c 100644 (file)
@@ -874,6 +874,9 @@ storage
 
 # ------ web archive support
 webarchive
 
 # ------ web archive support
 webarchive
+svg/webarchive
+svg/custom/image-with-prefix-in-webarchive.svg
+http/tests/webarchive
 
 # ----- XSLT currently not supported
 fast/xsl
 
 # ----- XSLT currently not supported
 fast/xsl
@@ -1127,7 +1130,6 @@ svg/custom/acid3-test-77.html
 svg/custom/baseval-animval-equality.svg
 svg/custom/frame-getSVGDocument.html
 svg/custom/image-clipped-hit.svg
 svg/custom/baseval-animval-equality.svg
 svg/custom/frame-getSVGDocument.html
 svg/custom/image-clipped-hit.svg
-svg/custom/image-with-prefix-in-webarchive.svg
 svg/custom/stroke-width-click.svg
 svg/custom/svg-features.html
 svg/custom/text-ctm.svg
 svg/custom/stroke-width-click.svg
 svg/custom/svg-features.html
 svg/custom/text-ctm.svg
@@ -1141,9 +1143,6 @@ svg/dom/font-face-elements.html
 svg/dom/SVGRectElement/rect-modify-rx.svg
 svg/hixie/dynamic/002.xml
 svg/hixie/mixed/007.xml
 svg/dom/SVGRectElement/rect-modify-rx.svg
 svg/hixie/dynamic/002.xml
 svg/hixie/mixed/007.xml
-svg/webarchive/svg-cursor-subresources.svg
-svg/webarchive/svg-feimage-subresources.svg
-svg/webarchive/svg-script-subresouces.svg
 tables/mozilla/bugs/bug51140.html
 tables/mozilla/bugs/bug103533.html
 tables/mozilla/marvin/backgr_index.html
 tables/mozilla/bugs/bug51140.html
 tables/mozilla/bugs/bug103533.html
 tables/mozilla/marvin/backgr_index.html
index 42a9be0..d69cd29 100644 (file)
@@ -165,6 +165,7 @@ svg/W3C-SVG-1.1/fonts-elem-07-b.svg
 webarchive
 svg/webarchive
 svg/custom/image-with-prefix-in-webarchive.svg
 webarchive
 svg/webarchive
 svg/custom/image-with-prefix-in-webarchive.svg
+http/tests/webarchive
 
 # <rdar://problem/5230396> layoutTestController.addFileToPasteboardOnDrag is unimplemented
 fast/forms/dragging-to-file-input.html
 
 # <rdar://problem/5230396> layoutTestController.addFileToPasteboardOnDrag is unimplemented
 fast/forms/dragging-to-file-input.html
index 4697b36..e2e8549 100644 (file)
@@ -1,3 +1,21 @@
+2008-12-01  David Kilzer  <ddkilzer@apple.com>
+
+        Bug 22466: REGRESSION (35867): Many resources missing when saving webarchive of webkit.org
+
+        <https://bugs.webkit.org/show_bug.cgi?id=22466>
+        <rdar://problem/6403593>
+
+        Reviewed by Brady Eidson.
+
+        Test: http/tests/webarchive/test-preload-resources.html
+
+        * loader/archive/cf/LegacyWebArchive.cpp:
+        (WebCore::LegacyWebArchive::create): Check the WebCore cache for
+        resources if DocumentLoader::subresource() doesn't return them.
+        Note that the DocumentLoader::subresource() method returned
+        preloaded resources before r35867, but this caused a regression in
+        Mail.
+
 2008-12-01  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Reviewed by Eric Seidel.
 2008-12-01  Julien Chaffraix  <jchaffraix@webkit.org>
 
         Reviewed by Eric Seidel.
index 9d99588..2f01a56 100644 (file)
@@ -30,6 +30,7 @@
 #include "LegacyWebArchive.h"
 
 #include "CString.h"
 #include "LegacyWebArchive.h"
 
 #include "CString.h"
+#include "Cache.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
 #include "Document.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
@@ -515,13 +516,25 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString
             for (unsigned i = 0; i < subresourceURLs.size(); ++i) {
                 if (uniqueSubresources.contains(subresourceURLs[i].string()))
                     continue;
             for (unsigned i = 0; i < subresourceURLs.size(); ++i) {
                 if (uniqueSubresources.contains(subresourceURLs[i].string()))
                     continue;
+
                 uniqueSubresources.add(subresourceURLs[i].string());
                 uniqueSubresources.add(subresourceURLs[i].string());
+
                 RefPtr<ArchiveResource> resource = documentLoader->subresource(subresourceURLs[i]);
                 RefPtr<ArchiveResource> resource = documentLoader->subresource(subresourceURLs[i]);
-                if (resource)
+                if (resource) {
                     subresources.append(resource.release());
                     subresources.append(resource.release());
-                else
-                    // FIXME: should do something better than spew to console here
-                    LOG_ERROR("Failed to archive subresource for %s", subresourceURLs[i].string().utf8().data());
+                    continue;
+                }
+
+                CachedResource *cachedResource = cache()->resourceForURL(subresourceURLs[i]);
+                if (cachedResource) {
+                    resource = ArchiveResource::create(cachedResource->data(), subresourceURLs[i], cachedResource->response());
+                    if (resource)
+                        subresources.append(resource.release());
+                    continue;
+                }
+
+                // FIXME: should do something better than spew to console here
+                LOG_ERROR("Failed to archive subresource for %s", subresourceURLs[i].string().utf8().data());
             }
         }
     }
             }
         }
     }
index 1c14f9a..e6acb30 100644 (file)
@@ -1,3 +1,20 @@
+2008-12-01  David Kilzer  <ddkilzer@apple.com>
+
+        Bug 22466: REGRESSION (35867): Many resources missing when saving webarchive of webkit.org
+
+        <https://bugs.webkit.org/show_bug.cgi?id=22466>
+        <rdar://problem/6403593>
+
+        Reviewed by Brady Eidson.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (normalizeHTTPResponseHeaderFields): Added.  Normalizes Date, Etag,
+        Keep-Alive, Last-Modified and Server header fields to prevent false
+        positive test failures.
+        (convertWebResourceResponseToDictionary): Call
+        normalizeHTTPResponseHeaderFields() to noramlize HTTP response
+        header fields.
+
 2008-12-01  David D. Kilzer  <ddkilzer@webkit.org>
 
         Bug 22559: Report builds left to test in bisect-builds (like git-bisect)
 2008-12-01  David D. Kilzer  <ddkilzer@webkit.org>
 
         Bug 22559: Report builds left to test in bisect-builds (like git-bisect)
index c170108..afb2b0d 100644 (file)
@@ -688,6 +688,20 @@ static void convertWebResourceDataToString(NSMutableDictionary *resource)
     }
 }
 
     }
 }
 
+static void normalizeHTTPResponseHeaderFields(NSMutableDictionary *fields)
+{
+    if ([fields objectForKey:@"Date"])
+        [fields setObject:@"Sun, 16 Nov 2008 17:00:00 GMT" forKey:@"Date"];
+    if ([fields objectForKey:@"Last-Modified"])
+        [fields setObject:@"Sun, 16 Nov 2008 16:55:00 GMT" forKey:@"Last-Modified"];
+    if ([fields objectForKey:@"Keep-Alive"])
+        [fields setObject:@"timeout=15" forKey:@"Keep-Alive"];
+    if ([fields objectForKey:@"Etag"])
+        [fields setObject:@"\"301925-21-45c7d72d3e780\"" forKey:@"Etag"];
+    if ([fields objectForKey:@"Server"])
+        [fields setObject:@"Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7l PHP/5.2.6" forKey:@"Server"];
+}
+
 static void normalizeWebResourceURL(NSMutableString *webResourceURL)
 {
     static int fileUrlLength = [(NSString *)@"file://" length];
 static void normalizeWebResourceURL(NSMutableString *webResourceURL)
 {
     static int fileUrlLength = [(NSString *)@"file://" length];
@@ -709,14 +723,14 @@ static void convertWebResourceResponseToDictionary(NSMutableDictionary *property
         [unarchiver finishDecoding];
         [unarchiver release];
     }        
         [unarchiver finishDecoding];
         [unarchiver release];
     }        
-    
+
     NSMutableDictionary *responseDictionary = [[NSMutableDictionary alloc] init];
     NSMutableDictionary *responseDictionary = [[NSMutableDictionary alloc] init];
-    
+
     NSMutableString *urlString = [[[response URL] description] mutableCopy];
     normalizeWebResourceURL(urlString);
     [responseDictionary setObject:urlString forKey:@"URL"];
     [urlString release];
     NSMutableString *urlString = [[[response URL] description] mutableCopy];
     normalizeWebResourceURL(urlString);
     [responseDictionary setObject:urlString forKey:@"URL"];
     [urlString release];
-    
+
     NSMutableString *mimeTypeString = [[response MIMEType] mutableCopy];
     convertMIMEType(mimeTypeString);
     [responseDictionary setObject:mimeTypeString forKey:@"MIMEType"];
     NSMutableString *mimeTypeString = [[response MIMEType] mutableCopy];
     convertMIMEType(mimeTypeString);
     [responseDictionary setObject:mimeTypeString forKey:@"MIMEType"];
@@ -726,14 +740,18 @@ static void convertWebResourceResponseToDictionary(NSMutableDictionary *property
     if (textEncodingName)
         [responseDictionary setObject:textEncodingName forKey:@"textEncodingName"];
     [responseDictionary setObject:[NSNumber numberWithLongLong:[response expectedContentLength]] forKey:@"expectedContentLength"];
     if (textEncodingName)
         [responseDictionary setObject:textEncodingName forKey:@"textEncodingName"];
     [responseDictionary setObject:[NSNumber numberWithLongLong:[response expectedContentLength]] forKey:@"expectedContentLength"];
-    
+
     if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
     if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
         NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
-        
-        [responseDictionary setObject:[httpResponse allHeaderFields] forKey:@"allHeaderFields"];
+
+        NSMutableDictionary *allHeaderFields = [[httpResponse allHeaderFields] mutableCopy];
+        normalizeHTTPResponseHeaderFields(allHeaderFields);
+        [responseDictionary setObject:allHeaderFields forKey:@"allHeaderFields"];
+        [allHeaderFields release];
+
         [responseDictionary setObject:[NSNumber numberWithInt:[httpResponse statusCode]] forKey:@"statusCode"];
     }
         [responseDictionary setObject:[NSNumber numberWithInt:[httpResponse statusCode]] forKey:@"statusCode"];
     }
-    
+
     [propertyList setObject:responseDictionary forKey:@"WebResourceResponse"];
     [responseDictionary release];
 }
     [propertyList setObject:responseDictionary forKey:@"WebResourceResponse"];
     [responseDictionary release];
 }