<!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>[244594] trunk/Tools</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/244594">244594</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2019-04-24 10:14:47 -0700 (Wed, 24 Apr 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add unit test for <a href="http://trac.webkit.org/projects/webkit/changeset/239322">r239322</a>
https://bugs.webkit.org/show_bug.cgi?id=197236

Reviewed by Chris Dumez.

I initially developed this as a unit test for rdar://problem/48797895 but it seems that isn't quite ready.
May as well add the test infrastructure which was needed before and will be needed in the future.

* TestWebKitAPI/TCPServer.cpp:
(TestWebKitAPI::TCPServer::TCPServer):
* TestWebKitAPI/TCPServer.h:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
(TestWebKitAPI::downloadAtRate):
* TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm:
(TEST):
* TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm: Added.
(-[ProxyDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[ProxyDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm:
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITCPServercpp">trunk/Tools/TestWebKitAPI/TCPServer.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPITCPServerh">trunk/Tools/TestWebKitAPI/TCPServer.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaChallengemm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaDownloadmm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaPDFLinkReferrermm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaWKNavigationResponsemm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaProxymm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/ChangeLog       2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2019-04-24  Alex Christensen  <achristensen@webkit.org>
+
+        Add unit test for r239322
+        https://bugs.webkit.org/show_bug.cgi?id=197236
+
+        Reviewed by Chris Dumez.
+
+        I initially developed this as a unit test for rdar://problem/48797895 but it seems that isn't quite ready.
+        May as well add the test infrastructure which was needed before and will be needed in the future.
+
+        * TestWebKitAPI/TCPServer.cpp:
+        (TestWebKitAPI::TCPServer::TCPServer):
+        * TestWebKitAPI/TCPServer.h:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/Download.mm:
+        (TestWebKitAPI::downloadAtRate):
+        * TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm:
+        (TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm: Added.
+        (-[ProxyDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (-[ProxyDelegate webView:didReceiveAuthenticationChallenge:completionHandler:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm:
+        (TEST):
+
</ins><span class="cx"> 2019-04-24  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         URL set by document.open() is communicated with the WebPageProxy but not the WebFrameProxy
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITCPServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TCPServer.cpp (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TCPServer.cpp  2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/TCPServer.cpp     2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -99,9 +99,9 @@
</span><span class="cx">     listenForConnections(connections);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TCPServer::TCPServer(Function<void(SSL*)>&& secureConnectionHandler)
-    : m_connectionHandler([secureConnectionHandler = WTFMove(secureConnectionHandler)] (Socket socket) {
-
</del><ins>+TCPServer::TCPServer(Protocol protocol, Function<void(SSL*)>&& secureConnectionHandler)
+{
+    auto startSecureConnection = [secureConnectionHandler = WTFMove(secureConnectionHandler)] (Socket socket) {
</ins><span class="cx">         SSL_library_init();
</span><span class="cx"> 
</span><span class="cx">         std::unique_ptr<SSL_CTX, deleter<SSL_CTX>> ctx(SSL_CTX_new(SSLv23_server_method()));
</span><span class="lines">@@ -160,8 +160,28 @@
</span><span class="cx">         ASSERT_UNUSED(acceptResult, acceptResult > 0);
</span><span class="cx">         
</span><span class="cx">         secureConnectionHandler(ssl.get());
</span><del>-    })
-{
</del><ins>+    };
+
+    switch (protocol) {
+    case Protocol::HTTPS:
+        m_connectionHandler = WTFMove(startSecureConnection);
+        break;
+    case Protocol::HTTPSProxy:
+        m_connectionHandler = [startSecureConnection = WTFMove(startSecureConnection)] (Socket socket) {
+            char readBuffer[1000];
+            auto bytesRead = ::read(socket, readBuffer, sizeof(readBuffer));
+            EXPECT_GT(bytesRead, 0);
+            EXPECT_TRUE(static_cast<size_t>(bytesRead) < sizeof(readBuffer));
+            
+            const char* responseHeader = ""
+            "HTTP/1.1 200 Connection Established\r\n"
+            "Connection: close\r\n\r\n";
+            auto bytesWritten = ::write(socket, responseHeader, strlen(responseHeader));
+            EXPECT_EQ(static_cast<size_t>(bytesWritten), strlen(responseHeader));
+            startSecureConnection(socket);
+        };
+        break;
+    }
</ins><span class="cx">     listenForConnections(1);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITCPServerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TCPServer.h (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TCPServer.h    2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/TCPServer.h       2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -43,8 +43,11 @@
</span><span class="cx">     using Port = uint16_t;
</span><span class="cx">     static constexpr Port InvalidPort = 0;
</span><span class="cx">     
</span><del>-    TCPServer(Function<void(Socket)>&&, size_t connections);
-    TCPServer(Function<void(SSL*)>&&);
</del><ins>+    TCPServer(Function<void(Socket)>&&, size_t connections = 1);
+    enum class Protocol : bool {
+        HTTPS, HTTPSProxy
+    };
+    TCPServer(Protocol, Function<void(SSL*)>&&);
</ins><span class="cx">     ~TCPServer();
</span><span class="cx">     
</span><span class="cx">     Port port() const { return m_port; }
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -347,6 +347,7 @@
</span><span class="cx">          5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; };
</span><span class="cx">          5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */; };
</span><span class="cx">          5CFACF63226F73C60056C7D0 /* libboringssl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFACF62226F73C60056C7D0 /* libboringssl.a */; };
</span><ins>+               5CFACF65226FD2DC0056C7D0 /* Proxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CFACF64226FD1FB0056C7D0 /* Proxy.mm */; };
</ins><span class="cx">           5E4B1D2E1D404C6100053621 /* WKScrollViewDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */; };
</span><span class="cx">          631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */; };
</span><span class="cx">          634910E01E9D3FF300880309 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 634910DF1E9D3FF300880309 /* CoreLocation.framework */; };
</span><span class="lines">@@ -1764,6 +1765,7 @@
</span><span class="cx">          5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; };
</span><span class="cx">          5CF540E82257E64B00E6BC0E /* DownloadThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadThread.mm; sourceTree = "<group>"; };
</span><span class="cx">          5CFACF62226F73C60056C7D0 /* libboringssl.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libboringssl.a; sourceTree = BUILT_PRODUCTS_DIR; };
</span><ins>+               5CFACF64226FD1FB0056C7D0 /* Proxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Proxy.mm; sourceTree = "<group>"; };
</ins><span class="cx">           5E4B1D2C1D404C6100053621 /* WKScrollViewDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegate.mm; path = ../ios/WKScrollViewDelegate.mm; sourceTree = "<group>"; };
</span><span class="cx">          631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Geolocation.mm; sourceTree = "<group>"; };
</span><span class="cx">          634910DF1E9D3FF300880309 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
</span><span class="lines">@@ -2645,6 +2647,7 @@
</span><span class="cx">                          CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */,
</span><span class="cx">                          518C1152205B04F9001FF4AE /* ProcessSwapOnNavigation.mm */,
</span><span class="cx">                          5798E2AF1CAF5C2800C5CBA0 /* ProvisionalURLNotChange.mm */,
</span><ins>+                               5CFACF64226FD1FB0056C7D0 /* Proxy.mm */,
</ins><span class="cx">                           A1C4FB6C1BACCE50003742D0 /* QuickLook.mm */,
</span><span class="cx">                          1A4F81D01BDFFDCF004E672E /* RemoteObjectRegistry.h */,
</span><span class="cx">                          1A4F81C81BDFFD18004E672E /* RemoteObjectRegistry.mm */,
</span><span class="lines">@@ -4290,6 +4293,7 @@
</span><span class="cx">                          CDA4438E21F7A47700379489 /* ProcessSuspendMediaBuffering.mm in Sources */,
</span><span class="cx">                          518C1153205B0504001FF4AE /* ProcessSwapOnNavigation.mm in Sources */,
</span><span class="cx">                          7C83E0C11D0A652F00FEBCF3 /* ProvisionalURLNotChange.mm in Sources */,
</span><ins>+                               5CFACF65226FD2DC0056C7D0 /* Proxy.mm in Sources */,
</ins><span class="cx">                           041A1E34216FFDBC00789E0A /* PublicSuffix.cpp in Sources */,
</span><span class="cx">                          7C83E0C21D0A653500FEBCF3 /* QuickLook.mm in Sources */,
</span><span class="cx">                          6B4E861C2220A5520022F389 /* RegistrableDomain.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaChallengemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm 2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm    2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -238,7 +238,7 @@
</span><span class="cx"> 
</span><span class="cx"> TEST(Challenge, SecIdentity)
</span><span class="cx"> {
</span><del>-    TCPServer server(respondWithChallengeThenOK, 1);
</del><ins>+    TCPServer server(respondWithChallengeThenOK);
</ins><span class="cx"> 
</span><span class="cx">     auto webView = adoptNS([WKWebView new]);
</span><span class="cx">     auto delegate = adoptNS([ChallengeDelegate new]);
</span><span class="lines">@@ -401,7 +401,7 @@
</span><span class="cx"> 
</span><span class="cx"> TEST(WebKit, ServerTrust)
</span><span class="cx"> {
</span><del>-    TCPServer server([] (SSL* ssl) {
</del><ins>+    TCPServer server(TCPServer::Protocol::HTTPS, [] (SSL* ssl) {
</ins><span class="cx">         char requestBuffer[1000];
</span><span class="cx">         auto readResult = SSL_read(ssl, requestBuffer, sizeof(requestBuffer));
</span><span class="cx">         ASSERT_UNUSED(readResult, readResult > 0);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaDownloadmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm  2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm     2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -863,7 +863,7 @@
</span><span class="cx">     bool terminateServer = false;
</span><span class="cx">     TCPServer server([&](int socket) {
</span><span class="cx">         respondSlowly(socket, desiredKbps, terminateServer);
</span><del>-    }, 1);
</del><ins>+    });
</ins><span class="cx">     
</span><span class="cx">     auto webView = webViewWithDownloadMonitorSpeedMultiplier(speedMultiplier);
</span><span class="cx">     [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/", server.port()]]]];
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaPDFLinkReferrermm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm   2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/PDFLinkReferrer.mm      2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx">         "HTTP/1.1 200 OK\r\n"
</span><span class="cx">         "Content-Length: 0\r\n\r\n";
</span><span class="cx">         ::write(socket, responseHeader, strlen(responseHeader));
</span><del>-    }, 1);
</del><ins>+    });
</ins><span class="cx"> 
</span><span class="cx">     RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaProxymm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm (0 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm                             (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Proxy.mm        2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -0,0 +1,87 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "TCPServer.h"
+#import "Utilities.h"
+#import <WebKit/WKWebsiteDataStorePrivate.h>
+#import <WebKit/WebKit.h>
+#import <WebKit/_WKWebsiteDataStoreConfiguration.h>
+#import <wtf/RetainPtr.h>
+
+static bool receivedAlert;
+
+@interface ProxyDelegate : NSObject <WKNavigationDelegate, WKUIDelegate>
+@end
+
+@implementation ProxyDelegate
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
+{
+    EXPECT_TRUE([message isEqualToString:@"success!"]);
+    receivedAlert = true;
+    completionHandler();
+}
+
+- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential))completionHandler
+{
+    completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+}
+
+@end
+
+namespace TestWebKitAPI {
+
+TEST(WebKit, HTTPSProxy)
+{
+    TCPServer server(TCPServer::Protocol::HTTPSProxy, [] (SSL* ssl) {
+        char requestBuffer[1000];
+        auto readResult = SSL_read(ssl, requestBuffer, sizeof(requestBuffer));
+        ASSERT_UNUSED(readResult, readResult > 0);
+
+        const char* reply = ""
+        "HTTP/1.1 200 OK\r\n"
+        "Content-Length: 34\r\n\r\n"
+        "<script>alert('success!')</script>";
+        auto writeResult = SSL_write(ssl, reply, strlen(reply));
+        ASSERT_UNUSED(writeResult, writeResult == static_cast<int>(strlen(reply)));
+    });
+
+    auto storeConfiguration = adoptNS([_WKWebsiteDataStoreConfiguration new]);
+    [storeConfiguration setHTTPSProxy:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]];
+    auto viewConfiguration = adoptNS([WKWebViewConfiguration new]);
+    [viewConfiguration setWebsiteDataStore:[[[WKWebsiteDataStore alloc] _initWithConfiguration:storeConfiguration.get()] autorelease]];
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:viewConfiguration.get()]);
+    auto delegate = adoptNS([ProxyDelegate new]);
+    [webView setNavigationDelegate:delegate.get()];
+    [webView setUIDelegate:delegate.get()];
+
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://example.com/"]]];
+    TestWebKitAPI::Util::run(&receivedAlert);
+}
+
+} // namespace TestWebKitAPI
+
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaWKNavigationResponsemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm (244593 => 244594)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm      2019-04-24 16:21:31 UTC (rev 244593)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKNavigationResponse.mm 2019-04-24 17:14:47 UTC (rev 244594)
</span><span class="lines">@@ -230,7 +230,7 @@
</span><span class="cx">                 "Content-Disposition: attachment; filename=fromHeader.txt;\r\n\r\n"
</span><span class="cx">                 "Hello!"
</span><span class="cx">             );
</span><del>-        }, 1);
</del><ins>+        });
</ins><span class="cx">         auto delegate = adoptNS([NavigationResponseTestDelegate new]);
</span><span class="cx">         auto webView = adoptNS([WKWebView new]);
</span><span class="cx">         [webView setNavigationDelegate:delegate.get()];
</span></span></pre>
</div>
</div>

</body>
</html>