Title: [174866] trunk
Revision
174866
Author
an...@apple.com
Date
2014-10-18 15:54:14 -0700 (Sat, 18 Oct 2014)

Log Message

REGRESSION (r173356): Safari can't install a profile, gets 'Download Failed error
https://bugs.webkit.org/show_bug.cgi?id=137855

Reviewed by Dan Bernstein.

Source/WebCore:

We lose the sniffed MIME type for the response when synthesizing an NSURLResponse. Sniffing requires
backchannel data that the synthesized response doesn't have.

Test: http/tests/mime/mime-type-sniff.html

* platform/network/mac/ResourceResponseMac.mm:
(WebCore::ResourceResponse::initNSURLResponse):

    When synthesizing NSURLResponse explicitly set the Content-type header to the sniffed type.

Tools:

Test and warn if the dumped response mime type differs from the platform response mime type.

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::didReceiveResponseForResource):
(WTR::InjectedBundlePage::platformResponseMimeType):
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
* WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm:
(WTR::InjectedBundlePage::platformResponseMimeType):

LayoutTests:

* http/tests/mime/mime-type-sniff-expected.txt: Added.
* http/tests/mime/mime-type-sniff.html: Added.
* http/tests/mime/resources/png-with-text-content-type.cgi: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174865 => 174866)


--- trunk/LayoutTests/ChangeLog	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/LayoutTests/ChangeLog	2014-10-18 22:54:14 UTC (rev 174866)
@@ -1,3 +1,14 @@
+2014-10-18  Antti Koivisto  <an...@apple.com>
+
+        REGRESSION (r173356): Safari can't install a profile, gets 'Download Failed error
+        https://bugs.webkit.org/show_bug.cgi?id=137855
+
+        Reviewed by Dan Bernstein.
+
+        * http/tests/mime/mime-type-sniff-expected.txt: Added.
+        * http/tests/mime/mime-type-sniff.html: Added.
+        * http/tests/mime/resources/png-with-text-content-type.cgi: Added.
+
 2014-10-18  Chris Fleizach  <cfleiz...@apple.com>
 
         AX: Tables with <colgroups> are not reporting table column headers

Added: trunk/LayoutTests/http/tests/mime/mime-type-sniff-expected.txt (0 => 174866)


--- trunk/LayoutTests/http/tests/mime/mime-type-sniff-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/mime/mime-type-sniff-expected.txt	2014-10-18 22:54:14 UTC (rev 174866)
@@ -0,0 +1,2 @@
+png-with-text-content-type.cgi has MIME type image/png
+

Added: trunk/LayoutTests/http/tests/mime/mime-type-sniff.html (0 => 174866)


--- trunk/LayoutTests/http/tests/mime/mime-type-sniff.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/mime/mime-type-sniff.html	2014-10-18 22:54:14 UTC (rev 174866)
@@ -0,0 +1,8 @@
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpResourceResponseMIMETypes();
+    testRunner.dumpAsText();
+}
+</script>
+<img src="" _onload_="testRunner.notifyDone()">

Added: trunk/LayoutTests/http/tests/mime/resources/png-with-text-content-type.cgi (0 => 174866)


--- trunk/LayoutTests/http/tests/mime/resources/png-with-text-content-type.cgi	                        (rev 0)
+++ trunk/LayoutTests/http/tests/mime/resources/png-with-text-content-type.cgi	2014-10-18 22:54:14 UTC (rev 174866)
@@ -0,0 +1,16 @@
+#!/usr/bin/perl -w
+
+use CGI;
+use HTTP::Date;
+
+print "Content-type: text/plain\n";
+print "\n";
+
+my $file = "../../css/resources/abe.png";
+
+open (FH,'<', $file) || die "Could not open $file: $!";
+my $buffer = "";
+while (read(FH, $buffer, 10240)) {
+    print $buffer;
+}
+close(FH);
Property changes on: trunk/LayoutTests/http/tests/mime/resources/png-with-text-content-type.cgi
___________________________________________________________________

Added: svn:executable

Modified: trunk/Source/WebCore/ChangeLog (174865 => 174866)


--- trunk/Source/WebCore/ChangeLog	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/Source/WebCore/ChangeLog	2014-10-18 22:54:14 UTC (rev 174866)
@@ -1,3 +1,20 @@
+2014-10-18  Antti Koivisto  <an...@apple.com>
+
+        REGRESSION (r173356): Safari can't install a profile, gets 'Download Failed error
+        https://bugs.webkit.org/show_bug.cgi?id=137855
+
+        Reviewed by Dan Bernstein.
+
+        We lose the sniffed MIME type for the response when synthesizing an NSURLResponse. Sniffing requires
+        backchannel data that the synthesized response doesn't have.
+
+        Test: http/tests/mime/mime-type-sniff.html
+
+        * platform/network/mac/ResourceResponseMac.mm:
+        (WebCore::ResourceResponse::initNSURLResponse):
+
+            When synthesizing NSURLResponse explicitly set the Content-type header to the sniffed type.
+
 2014-10-18  Chris Dumez  <cdu...@apple.com>
 
         [Mac] Use Fast enumeration consistently in WebFontCache.mm

Modified: trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm (174865 => 174866)


--- trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/Source/WebCore/platform/network/mac/ResourceResponseMac.mm	2014-10-18 22:54:14 UTC (rev 174866)
@@ -66,6 +66,9 @@
         [headerDictionary setObject:(NSString *)header.value forKey:(NSString *)header.key];
 
     m_nsResponse = adoptNS([[NSHTTPURLResponse alloc] initWithURL:m_url statusCode:m_httpStatusCode HTTPVersion:(NSString*)kCFHTTPVersion1_1 headerFields:headerDictionary]);
+
+    // Mime type sniffing doesn't work with a synthesized response.
+    [m_nsResponse.get() _setMIMEType:(NSString *)m_mimeType];
 }
 
 #if USE(CFNETWORK)

Modified: trunk/Tools/ChangeLog (174865 => 174866)


--- trunk/Tools/ChangeLog	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/Tools/ChangeLog	2014-10-18 22:54:14 UTC (rev 174866)
@@ -1,3 +1,19 @@
+2014-10-18  Antti Koivisto  <an...@apple.com>
+
+        REGRESSION (r173356): Safari can't install a profile, gets 'Download Failed error
+        https://bugs.webkit.org/show_bug.cgi?id=137855
+
+        Reviewed by Dan Bernstein.
+
+        Test and warn if the dumped response mime type differs from the platform response mime type.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::didReceiveResponseForResource):
+        (WTR::InjectedBundlePage::platformResponseMimeType):
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.h:
+        * WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm:
+        (WTR::InjectedBundlePage::platformResponseMimeType):
+
 2014-10-17  Joseph Pecoraro  <pecor...@apple.com>
 
         Remove run-inspector-perf-tests.py there is no PerformanceTests/inspector anymore

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (174865 => 174866)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2014-10-18 22:54:14 UTC (rev 174866)
@@ -1131,7 +1131,15 @@
     stringBuilder.append(toWTFString(urlString));
     stringBuilder.appendLiteral(" has MIME type ");
     stringBuilder.append(toWTFString(mimeTypeString));
+
+    String platformMimeType = platformResponseMimeType(response);
+    if (!platformMimeType.isEmpty() && platformMimeType != toWTFString(mimeTypeString)) {
+        stringBuilder.appendLiteral(" but platform response has ");
+        stringBuilder.append(platformMimeType);
+    }
+
     stringBuilder.append('\n');
+
     InjectedBundle::shared().outputText(stringBuilder.toString());
 }
 
@@ -1867,6 +1875,11 @@
 void InjectedBundlePage::platformDidStartProvisionalLoadForFrame(WKBundleFrameRef)
 {
 }
+
+String InjectedBundlePage::platformResponseMimeType(WKURLResponseRef)
+{
+    return String();
+}
 #endif
 
 void InjectedBundlePage::frameDidChangeLocation(WKBundleFrameRef frame, bool shouldDump)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h (174865 => 174866)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.h	2014-10-18 22:54:14 UTC (rev 174866)
@@ -169,6 +169,7 @@
     void dumpDOMAsWebArchive(WKBundleFrameRef, WTF::StringBuilder&);
 
     void platformDidStartProvisionalLoadForFrame(WKBundleFrameRef);
+    String platformResponseMimeType(WKURLResponseRef);
 
     void frameDidChangeLocation(WKBundleFrameRef, bool shouldDump = false);
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm (174865 => 174866)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm	2014-10-18 21:48:33 UTC (rev 174865)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/cocoa/InjectedBundlePageCocoa.mm	2014-10-18 22:54:14 UTC (rev 174866)
@@ -30,6 +30,7 @@
 #import <WebKit/WKBundleFrame.h>
 #import <WebKit/WKBundlePagePrivate.h>
 #import <WebKit/WKURLCF.h>
+#import <WebKit/WKURLResponseNS.h>
 
 namespace WTR {
 
@@ -48,4 +49,10 @@
 #endif
 }
 
+String InjectedBundlePage::platformResponseMimeType(WKURLResponseRef response)
+{
+    RetainPtr<NSURLResponse> nsURLResponse = adoptNS(WKURLResponseCopyNSURLResponse(response));
+    return [nsURLResponse.get() MIMEType];
+}
+
 } // namespace WTR
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to