<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[188517] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/188517">188517</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2015-08-15 20:29:01 -0700 (Sat, 15 Aug 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Cocoa] Add redirect support to CustomProtocolManager
https://bugs.webkit.org/show_bug.cgi?id=147871
Reviewed by Dan Bernstein.
Source/WebKit2:
NSURLProtocols have the ability to generate redirect responses. This change teaches CustomProtocolManager how to handle them.
* Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm:
(WebKit::CustomProtocolManager::wasRedirectedToRequest): Called -URLProtocol:wasRedirectedToRequest:redirectResponse: on the NSURLProtocolClient.
* Shared/Network/CustomProtocols/CustomProtocolManager.h:
* Shared/Network/CustomProtocols/CustomProtocolManager.messages.in: Defined WasRedirectedToRequest.
* Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp:
(WebKit::CustomProtocolManager::wasRedirectedToRequest): Defined empty function.
* UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm:
(-[WKCustomProtocolLoader connection:willSendRequest:redirectResponse:]): If a redirect response is received, send WasRedirectedToRequest and return nil to ignore the redirect.
Tools:
Updated WebKit2CustomProtocolsTest.MainResource to generate a redirect response.
* TestWebKitAPI/Tests/CustomProtocolsSyncXHRTest.mm:
(TestWebKitAPI::TEST): Unregesitered TestProtocol.
* TestWebKitAPI/Tests/WebKit2/custom-protocol-sync-xhr.html: Changed scheme to http.
* TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsTest.mm:
(-[CustomProtocolsLoadDelegate browsingContextControllerDidStartProvisionalLoad:]): Expected a certain provisional URL.
(-[CustomProtocolsLoadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:]): Ditto.
(-[CustomProtocolsLoadDelegate browsingContextControllerDidCommitLoad:]): Expected a certain committed URL.
(-[CustomProtocolsLoadDelegate browsingContextControllerDidFinishLoad:]): Expected isLoading to be false.
(TestWebKitAPI::TEST): Used the new load delegate and unregistered TestProtocol.
* TestWebKitAPI/Tests/WebKit2ObjC/PreventImageLoadWithAutoResizing.mm:
(TestWebKitAPI::TEST): Unregistered TestProtocol.
* TestWebKitAPI/mac/TestProtocol.mm: Changed scheme to http.
(+[TestProtocol canInitWithRequest:]): Changed to use property syntax.
(-[TestProtocol startLoading]): Taught to handle redirect responses.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedNetworkCustomProtocolsCocoaCustomProtocolManagerCocoamm">trunk/Source/WebKit2/Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedNetworkCustomProtocolsCustomProtocolManagerh">trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h</a></li>
<li><a href="#trunkSourceWebKit2SharedNetworkCustomProtocolsCustomProtocolManagermessagesin">trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in</a></li>
<li><a href="#trunkSourceWebKit2SharedNetworkCustomProtocolssoupCustomProtocolManagerSoupcpp">trunk/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessNetworkCustomProtocolsmacCustomProtocolManagerProxyMacmm">trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsCustomProtocolsSyncXHRTestmm">trunk/Tools/TestWebKitAPI/Tests/CustomProtocolsSyncXHRTest.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2customprotocolsyncxhrhtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2/custom-protocol-sync-xhr.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2ObjCCustomProtocolsTestmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsTest.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2ObjCPreventImageLoadWithAutoResizingmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/PreventImageLoadWithAutoResizing.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPImacTestProtocolmm">trunk/Tools/TestWebKitAPI/mac/TestProtocol.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Source/WebKit2/ChangeLog        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-08-11 Andy Estes <aestes@apple.com>
+
+ [Cocoa] Add redirect support to CustomProtocolManager
+ https://bugs.webkit.org/show_bug.cgi?id=147871
+
+ Reviewed by Dan Bernstein.
+
+ NSURLProtocols have the ability to generate redirect responses. This change teaches CustomProtocolManager how to handle them.
+
+ * Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm:
+ (WebKit::CustomProtocolManager::wasRedirectedToRequest): Called -URLProtocol:wasRedirectedToRequest:redirectResponse: on the NSURLProtocolClient.
+ * Shared/Network/CustomProtocols/CustomProtocolManager.h:
+ * Shared/Network/CustomProtocols/CustomProtocolManager.messages.in: Defined WasRedirectedToRequest.
+ * Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp:
+ (WebKit::CustomProtocolManager::wasRedirectedToRequest): Defined empty function.
+ * UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm:
+ (-[WKCustomProtocolLoader connection:willSendRequest:redirectResponse:]): If a redirect response is received, send WasRedirectedToRequest and return nil to ignore the redirect.
+
</ins><span class="cx"> 2015-08-13 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> [Cocoa] Downloads do not start if policy decision is made asynchronously
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNetworkCustomProtocolsCocoaCustomProtocolManagerCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/Cocoa/CustomProtocolManagerCocoa.mm        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -259,6 +259,20 @@
</span><span class="cx"> removeCustomProtocol(protocol.get());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CustomProtocolManager::wasRedirectedToRequest(uint64_t customProtocolID, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse)
+{
+ RetainPtr<WKCustomProtocol> protocol = protocolForID(customProtocolID);
+ if (!protocol)
+ return;
+
+ RetainPtr<NSURLRequest> nsRequest = request.nsURLRequest(WebCore::DoNotUpdateHTTPBody);
+ RetainPtr<NSURLResponse> nsRedirectResponse = redirectResponse.nsURLResponse();
+
+ dispatchOnResourceLoaderRunLoop([protocol, nsRequest, nsRedirectResponse]() {
+ [[protocol client] URLProtocol:protocol.get() wasRedirectedToRequest:nsRequest.get() redirectResponse:nsRedirectResponse.get()];
+ });
+}
+
</ins><span class="cx"> RetainPtr<WKCustomProtocol> CustomProtocolManager::protocolForID(uint64_t customProtocolID)
</span><span class="cx"> {
</span><span class="cx"> MutexLocker locker(m_customProtocolMapMutex);
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNetworkCustomProtocolsCustomProtocolManagerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class ResourceError;
</span><ins>+class ResourceRequest;
</ins><span class="cx"> class ResourceResponse;
</span><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="lines">@@ -94,6 +95,7 @@
</span><span class="cx"> void didLoadData(uint64_t customProtocolID, const IPC::DataReference&);
</span><span class="cx"> void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&, uint32_t cacheStoragePolicy);
</span><span class="cx"> void didFinishLoading(uint64_t customProtocolID);
</span><ins>+ void wasRedirectedToRequest(uint64_t customProtocolID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
</ins><span class="cx">
</span><span class="cx"> ChildProcess* m_childProcess;
</span><span class="cx"> RefPtr<WorkQueue> m_messageQueue;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNetworkCustomProtocolsCustomProtocolManagermessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> DidLoadData(uint64_t customProtocolID, IPC::DataReference data)
</span><span class="cx"> DidReceiveResponse(uint64_t customProtocolID, WebCore::ResourceResponse response, uint32_t cacheStoragePolicy)
</span><span class="cx"> DidFinishLoading(uint64_t customProtocolID)
</span><ins>+ WasRedirectedToRequest(uint64_t customProtocolID, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse);
</ins><span class="cx">
</span><span class="cx"> RegisterScheme(String name)
</span><span class="cx"> UnregisterScheme(String name)
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedNetworkCustomProtocolssoupCustomProtocolManagerSoupcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/soup/CustomProtocolManagerSoup.cpp        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -106,4 +106,9 @@
</span><span class="cx"> m_impl->didFinishLoading(customProtocolID);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CustomProtocolManager::wasRedirectedToRequest(uint64_t, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&)
+{
+ notImplemented();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessNetworkCustomProtocolsmacCustomProtocolManagerProxyMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -110,6 +110,10 @@
</span><span class="cx">
</span><span class="cx"> - (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
</span><span class="cx"> {
</span><ins>+ if (redirectResponse) {
+ _connection->send(Messages::CustomProtocolManager::WasRedirectedToRequest(_customProtocolID, request, redirectResponse), 0);
+ return nil;
+ }
</ins><span class="cx"> return request;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Tools/ChangeLog        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-08-11 Andy Estes <aestes@apple.com>
+
+ [Cocoa] Add redirect support to CustomProtocolManager
+ https://bugs.webkit.org/show_bug.cgi?id=147871
+
+ Reviewed by Dan Bernstein.
+
+ Updated WebKit2CustomProtocolsTest.MainResource to generate a redirect response.
+
+ * TestWebKitAPI/Tests/CustomProtocolsSyncXHRTest.mm:
+ (TestWebKitAPI::TEST): Unregesitered TestProtocol.
+ * TestWebKitAPI/Tests/WebKit2/custom-protocol-sync-xhr.html: Changed scheme to http.
+ * TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsTest.mm:
+ (-[CustomProtocolsLoadDelegate browsingContextControllerDidStartProvisionalLoad:]): Expected a certain provisional URL.
+ (-[CustomProtocolsLoadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:]): Ditto.
+ (-[CustomProtocolsLoadDelegate browsingContextControllerDidCommitLoad:]): Expected a certain committed URL.
+ (-[CustomProtocolsLoadDelegate browsingContextControllerDidFinishLoad:]): Expected isLoading to be false.
+ (TestWebKitAPI::TEST): Used the new load delegate and unregistered TestProtocol.
+ * TestWebKitAPI/Tests/WebKit2ObjC/PreventImageLoadWithAutoResizing.mm:
+ (TestWebKitAPI::TEST): Unregistered TestProtocol.
+ * TestWebKitAPI/mac/TestProtocol.mm: Changed scheme to http.
+ (+[TestProtocol canInitWithRequest:]): Changed to use property syntax.
+ (-[TestProtocol startLoading]): Taught to handle redirect responses.
+
</ins><span class="cx"> 2015-08-13 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> [Cocoa] Downloads do not start if policy decision is made asynchronously
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsCustomProtocolsSyncXHRTestmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/CustomProtocolsSyncXHRTest.mm (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/CustomProtocolsSyncXHRTest.mm        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Tools/TestWebKitAPI/Tests/CustomProtocolsSyncXHRTest.mm        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -69,6 +69,8 @@
</span><span class="cx"> WKPageLoadURL(wkView.get().pageRef, Util::createURLForResource("custom-protocol-sync-xhr", "html"));
</span><span class="cx">
</span><span class="cx"> TestWebKitAPI::Util::run(&testFinished);
</span><ins>+ [NSURLProtocol unregisterClass:[TestProtocol class]];
+ [WKBrowsingContextController unregisterSchemeForCustomProtocol:[TestProtocol scheme]];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2customprotocolsyncxhrhtml"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/custom-protocol-sync-xhr.html (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/custom-protocol-sync-xhr.html        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/custom-protocol-sync-xhr.html        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> <script>
</span><span class="cx"> var request = new XMLHttpRequest();
</span><del>- request.open('GET', 'test://test', false);
</del><ins>+ request.open('GET', 'http://test', false);
</ins><span class="cx"> request.send(null);
</span><span class="cx"> window._testResult = request.responseText;
</span><span class="cx"> </script>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2ObjCCustomProtocolsTestmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsTest.mm (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsTest.mm        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/CustomProtocolsTest.mm        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -39,6 +39,34 @@
</span><span class="cx">
</span><span class="cx"> static bool testFinished = false;
</span><span class="cx">
</span><ins>+@interface CustomProtocolsLoadDelegate : NSObject <WKBrowsingContextLoadDelegate>
+@end
+
+@implementation CustomProtocolsLoadDelegate
+
+- (void)browsingContextControllerDidStartProvisionalLoad:(WKBrowsingContextController *)sender
+{
+ EXPECT_TRUE([sender.provisionalURL.absoluteString isEqualToString:@"http://redirect/?test"]);
+}
+
+- (void)browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:(WKBrowsingContextController *)sender
+{
+ EXPECT_TRUE([sender.provisionalURL.absoluteString isEqualToString:@"http://test/"]);
+}
+
+- (void)browsingContextControllerDidCommitLoad:(WKBrowsingContextController *)sender
+{
+ EXPECT_TRUE([sender.committedURL.absoluteString isEqualToString:@"http://test/"]);
+}
+
+- (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender
+{
+ EXPECT_FALSE(sender.isLoading);
+ testFinished = true;
+}
+
+@end
+
</ins><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx">
</span><span class="cx"> TEST(WebKit2CustomProtocolsTest, MainResource)
</span><span class="lines">@@ -49,12 +77,13 @@
</span><span class="cx"> RetainPtr<WKProcessGroup> processGroup = adoptNS([[WKProcessGroup alloc] init]);
</span><span class="cx"> RetainPtr<WKBrowsingContextGroup> browsingContextGroup = adoptNS([[WKBrowsingContextGroup alloc] initWithIdentifier:@"TestIdentifier"]);
</span><span class="cx"> RetainPtr<WKView> wkView = adoptNS([[WKView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) processGroup:processGroup.get() browsingContextGroup:browsingContextGroup.get()]);
</span><del>- wkView.get().browsingContextController.loadDelegate = [[TestBrowsingContextLoadDelegate alloc] initWithBlockToRunOnLoad:^(WKBrowsingContextController *sender) {
- testFinished = true;
- }];
- [wkView.get().browsingContextController loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@://test", [TestProtocol scheme]]]]];
</del><ins>+ RetainPtr<CustomProtocolsLoadDelegate> loadDelegate = adoptNS([[CustomProtocolsLoadDelegate alloc] init]);
+ [wkView browsingContextController].loadDelegate = loadDelegate.get();
+ [[wkView browsingContextController] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@://redirect?test", [TestProtocol scheme]]]]];
</ins><span class="cx">
</span><span class="cx"> Util::run(&testFinished);
</span><ins>+ [NSURLProtocol unregisterClass:[TestProtocol class]];
+ [WKBrowsingContextController unregisterSchemeForCustomProtocol:[TestProtocol scheme]];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2ObjCPreventImageLoadWithAutoResizingmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/PreventImageLoadWithAutoResizing.mm (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/PreventImageLoadWithAutoResizing.mm        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2ObjC/PreventImageLoadWithAutoResizing.mm        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx"> [webView.platformView().browsingContextController loadHTMLString:@"<html><body style='background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAFZJREFUeF59z4EJADEIQ1F36k7u5E7ZKXeUQPACJ3wK7UNokVxVk9kHnQH7bY9hbDyDhNXgjpRLqFlo4M2GgfyJHhjq8V4agfrgPQX3JtJQGbofmCHgA/nAKks+JAjFAAAAAElFTkSuQmCC);'></body></html>" baseURL:[NSURL URLWithString:@"about:blank"]];
</span><span class="cx">
</span><span class="cx"> Util::run(&testFinished);
</span><ins>+ [NSURLProtocol unregisterClass:[TestProtocol class]];
+ [WKBrowsingContextController unregisterSchemeForCustomProtocol:[TestProtocol scheme]];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace TestWebKitAPI
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPImacTestProtocolmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/mac/TestProtocol.mm (188516 => 188517)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/mac/TestProtocol.mm        2015-08-15 20:48:25 UTC (rev 188516)
+++ trunk/Tools/TestWebKitAPI/mac/TestProtocol.mm        2015-08-16 03:29:01 UTC (rev 188517)
</span><span class="lines">@@ -26,13 +26,17 @@
</span><span class="cx"> #import "config.h"
</span><span class="cx"> #import "TestProtocol.h"
</span><span class="cx">
</span><del>-static NSString *testScheme = @"test";
</del><ins>+#import <wtf/RetainPtr.h>
</ins><span class="cx">
</span><ins>+// Even though NSURLProtocol is capable of generating redirect responses for any protocol, WebCore asserts if a redirect is not in the http family.
+// See http://webkit.org/b/147870 for details.
+static NSString *testScheme = @"http";
+
</ins><span class="cx"> @implementation TestProtocol
</span><span class="cx">
</span><span class="cx"> + (BOOL)canInitWithRequest:(NSURLRequest *)request
</span><span class="cx"> {
</span><del>- return [[[request URL] scheme] caseInsensitiveCompare:testScheme] == NSOrderedSame;
</del><ins>+ return [request.URL.scheme caseInsensitiveCompare:testScheme] == NSOrderedSame;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> + (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
</span><span class="lines">@@ -52,14 +56,21 @@
</span><span class="cx">
</span><span class="cx"> - (void)startLoading
</span><span class="cx"> {
</span><del>- EXPECT_TRUE([[[[self request] URL] scheme] isEqualToString:testScheme]);
-
</del><ins>+ NSURL *requestURL = self.request.URL;
+ EXPECT_TRUE([requestURL.scheme isEqualToString:testScheme]);
+
</ins><span class="cx"> NSData *data = [@"PASS" dataUsingEncoding:NSASCIIStringEncoding];
</span><del>- NSURLResponse *response = [[NSURLResponse alloc] initWithURL:[[self request] URL] MIMEType:@"text/html" expectedContentLength:[data length] textEncodingName:nil];
- [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
- [[self client] URLProtocol:self didLoadData:data];
- [[self client] URLProtocolDidFinishLoading:self];
- [response release];
</del><ins>+ RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:requestURL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil]);
+
+ if ([requestURL.host isEqualToString:@"redirect"]) {
+ NSURL *redirectURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@", testScheme, requestURL.query]];
+ [self.client URLProtocol:self wasRedirectedToRequest:[NSURLRequest requestWithURL:redirectURL] redirectResponse:response.get()];
+ return;
+ }
+
+ [self.client URLProtocol:self didReceiveResponse:response.get() cacheStoragePolicy:NSURLCacheStorageNotAllowed];
+ [self.client URLProtocol:self didLoadData:data];
+ [self.client URLProtocolDidFinishLoading:self];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)stopLoading
</span></span></pre>
</div>
</div>
</body>
</html>