Title: [201404] trunk
Revision
201404
Author
[email protected]
Date
2016-05-25 14:58:08 -0700 (Wed, 25 May 2016)

Log Message

[WebSockets] No infrastructure for testing secure web sockets (wss)
https://bugs.webkit.org/show_bug.cgi?id=157884
<rdar://problem/26477197>

Reviewed by Andy Estes.

Source/WebCore:

Add a new test-only flag used to tell CFNetwork that we do not wish to
validate the SLL certificate chain. This allows us to use self-signed
certificates in test cases.

Tests: http/tests/websocket/tests/hybi/simple-wss.html

* page/Settings.cpp:
(WebCore::Settings::setAllowsAnySSLCertificate): Added.
(WebCore::Settings::allowsAnySSLCertificate): Added. This defaults
to False.
* page/Settings.h:
* platform/network/cf/SocketStreamHandleCFNet.cpp:
(WebCore::SocketStreamHandle::createStreams): When running under our
testing infrastructure, do not require full certificate validation.
* testing/js/WebCoreTestSupport.cpp:
(WebCoreTestSupport::setAllowsAnySSLCertificate): Added.
* testing/js/WebCoreTestSupport.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setAllowsAnySSLCertificate): Added.
* testing/InternalSettings.h:

Tools:

Add support to webkitpy to start and stop a secure Web Socket server running on port 9323
using the certificate, private-key from file LayoutTests/http/conf/webkit-httpd.pem. Also
teaches run-webkit-httpd to start and stop the Web Socket servers.

Modify DumpRenderTree and WebKitTestRunner to understand a new testRunner method,
'setAllowsAnySSLCertificate', which allows us to use the same self-signed test certificate
we do for our HTTPS tests.
        
* DumpRenderTree/TestRunner.cpp:
(setAllowsAnySSLCertificateCallback):
(TestRunner::setAllowsAnySSLCertificate):
* DumpRenderTree/TestRunner.h:
* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebViewToConsistentStateBeforeTesting): Make sure we turn off the new flag between tests.
* Scripts/run-webkit-httpd:
(main): Start the websocket server at launch.
* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager.__init__): Remove dead code.
* Scripts/webkitpy/layout_tests/servers/websocket_server.py:
(PyWebSocket.__init__): Cleanup code.
(PyWebSocket): Pass '--tls-client-ca' to start command.
(PyWebSocket._prepare_config): Cleanups.
* Scripts/webkitpy/port/base.py:
(Port.to.start_http_server):
(Port.to):
(Port.to._extract_certificate_from_pem): Added.
(Port.to._extract_private_key_from_pem): Added.
(Port.to.start_websocket_server): Start secure socket server.
(Port.to.stop_websocket_server): Stop secure socket server.
* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Add new API.
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::setAllowsAnySSLCertificate): Added.
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::setAllowsAnySSLCertificate): Added.
* WebKitTestRunner/InjectedBundle/TestRunner.h:

LayoutTests:

* http/tests/websocket/tests/hybi/simple-wss-expected.txt: Added.
* http/tests/websocket/tests/hybi/simple-wss.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (201403 => 201404)


--- trunk/LayoutTests/ChangeLog	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/LayoutTests/ChangeLog	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,3 +1,14 @@
+2016-05-25  Daniel Bates  <[email protected]> and Brent Fulgham  <[email protected]>
+
+        [WebSockets] No infrastructure for testing secure web sockets (wss)
+        https://bugs.webkit.org/show_bug.cgi?id=157884
+        <rdar://problem/26477197>
+
+        Reviewed by Andy Estes.
+
+        * http/tests/websocket/tests/hybi/simple-wss-expected.txt: Added.
+        * http/tests/websocket/tests/hybi/simple-wss.html: Added.
+
 2016-05-25  Ryan Haddad  <[email protected]>
 
         Marking http/tests/css/shared-stylesheet-mutation.html as flaky

Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/simple-wss-expected.txt (0 => 201404)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/simple-wss-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/simple-wss-expected.txt	2016-05-25 21:58:08 UTC (rev 201404)
@@ -0,0 +1,12 @@
+Simple secure Web Socket test
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+Created a socket to 'wss://127.0.0.1:9323/websocket/tests/hybi/simple'; readyState 0.
+Connected; readyState 1
+Received: 'Hello from Simple WSH.'; readyState 1
+Closed; readyState 3.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/websocket/tests/hybi/simple-wss.html (0 => 201404)


--- trunk/LayoutTests/http/tests/websocket/tests/hybi/simple-wss.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/websocket/tests/hybi/simple-wss.html	2016-05-25 21:58:08 UTC (rev 201404)
@@ -0,0 +1,53 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<script type="text/_javascript_">
+description("Simple secure Web Socket test");
+
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setAllowsAnySSLCertificate(true);
+
+function endTest()
+{
+    clearTimeout(timeoutID);
+    finishJSTest();
+}
+
+var ws = new WebSocket("wss://127.0.0.1:9323/websocket/tests/hybi/simple");
+debug("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".");
+
+ws._onopen_ = function()
+{
+    debug("Connected; readyState " + ws.readyState);
+};
+
+ws._onmessage_ = function(messageEvent)
+{
+    debug("Received: '" + messageEvent.data + "'; readyState " + ws.readyState);
+};
+
+ws._onclose_ = function()
+{
+    debug("Closed; readyState " + ws.readyState + ".");
+    endTest();
+};
+
+function timeOutCallback()
+{
+    debug("Timed out in state: " + ws.readyState);
+    endTest();
+}
+
+var timeoutID = setTimeout(timeOutCallback, 3000);
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (201403 => 201404)


--- trunk/Source/WebCore/ChangeLog	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/ChangeLog	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,3 +1,32 @@
+2016-05-25  Brent Fulgham  <[email protected]>
+
+        [WebSockets] No infrastructure for testing secure web sockets (wss)
+        https://bugs.webkit.org/show_bug.cgi?id=157884
+        <rdar://problem/26477197>
+
+        Reviewed by Andy Estes.
+
+        Add a new test-only flag used to tell CFNetwork that we do not wish to
+        validate the SLL certificate chain. This allows us to use self-signed
+        certificates in test cases.
+
+        Tests: http/tests/websocket/tests/hybi/simple-wss.html
+
+        * page/Settings.cpp:
+        (WebCore::Settings::setAllowsAnySSLCertificate): Added.
+        (WebCore::Settings::allowsAnySSLCertificate): Added. This defaults
+        to False.
+        * page/Settings.h:
+        * platform/network/cf/SocketStreamHandleCFNet.cpp:
+        (WebCore::SocketStreamHandle::createStreams): When running under our
+        testing infrastructure, do not require full certificate validation.
+        * testing/js/WebCoreTestSupport.cpp:
+        (WebCoreTestSupport::setAllowsAnySSLCertificate): Added.
+        * testing/js/WebCoreTestSupport.h:
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::setAllowsAnySSLCertificate): Added.
+        * testing/InternalSettings.h:
+
 2016-05-25  Jer Noble  <[email protected]>
 
         CRASH at WebCore::WebPlaybackSessionModelMediaElement::selectAudioMediaOption() + 104

Modified: trunk/Source/WebCore/page/Settings.cpp (201403 => 201404)


--- trunk/Source/WebCore/page/Settings.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/page/Settings.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -101,6 +101,7 @@
 bool Settings::gShouldRespectPriorityInCSSAttributeSetters = false;
 bool Settings::gLowPowerVideoAudioBufferSizeEnabled = false;
 bool Settings::gResourceLoadStatisticsEnabledEnabled = false;
+bool Settings::gAllowsAnySSLCertificate = false;
 
 #if PLATFORM(IOS)
 bool Settings::gNetworkDataUsageTrackingEnabled = false;
@@ -754,4 +755,14 @@
 #endif
 }
 
+void Settings::setAllowsAnySSLCertificate(bool allowAnySSLCertificate)
+{
+    gAllowsAnySSLCertificate = allowAnySSLCertificate;
+}
+
+bool Settings::allowsAnySSLCertificate()
+{
+    return gAllowsAnySSLCertificate;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/Settings.h (201403 => 201404)


--- trunk/Source/WebCore/page/Settings.h	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/page/Settings.h	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2011, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2003-2016 Apple Inc. All rights reserved.
  *           (C) 2006 Graham Dennis ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without
@@ -285,7 +285,10 @@
 
     WEBCORE_EXPORT void setForcePendingWebGLPolicy(bool);
     bool isForcePendingWebGLPolicy() const { return m_forcePendingWebGLPolicy; }
-    
+
+    WEBCORE_EXPORT static void setAllowsAnySSLCertificate(bool);
+    static bool allowsAnySSLCertificate();
+
 #if USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/SettingsGettersAndSetters.h>
 #endif
@@ -381,6 +384,7 @@
 
     static bool gLowPowerVideoAudioBufferSizeEnabled;
     static bool gResourceLoadStatisticsEnabledEnabled;
+    static bool gAllowsAnySSLCertificate;
 
 #if USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/SettingsMembers.h>

Modified: trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp (201403 => 201404)


--- trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 Apple Inc.  All rights reserved.
+ * Copyright (C) 2009-2016 Apple Inc.  All rights reserved.
  * Copyright (C) 2009 Google Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,6 +37,7 @@
 #include "Logging.h"
 #include "NetworkingContext.h"
 #include "ProtectionSpace.h"
+#include "Settings.h"
 #include "SocketStreamError.h"
 #include "SocketStreamHandleClient.h"
 #include <wtf/Condition.h>
@@ -340,8 +341,9 @@
     }
 
     if (shouldUseSSL()) {
-        const void* keys[] = { kCFStreamSSLPeerName, kCFStreamSSLLevel };
-        const void* values[] = { host.get(), kCFStreamSocketSecurityLevelNegotiatedSSL };
+        CFBooleanRef validateCertificateChain = Settings::allowsAnySSLCertificate() ? kCFBooleanFalse : kCFBooleanTrue;
+        const void* keys[] = { kCFStreamSSLPeerName, kCFStreamSSLLevel, kCFStreamSSLValidatesCertificateChain };
+        const void* values[] = { host.get(), kCFStreamSocketSecurityLevelNegotiatedSSL, validateCertificateChain };
         RetainPtr<CFDictionaryRef> settings = adoptCF(CFDictionaryCreate(0, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
         CFReadStreamSetProperty(m_readStream.get(), kCFStreamPropertySSLSettings, settings.get());
         CFWriteStreamSetProperty(m_writeStream.get(), kCFStreamPropertySSLSettings, settings.get());

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (201403 => 201404)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -184,6 +184,7 @@
 #endif
     settings.setUserInterfaceDirectionPolicy(m_userInterfaceDirectionPolicy);
     settings.setSystemLayoutDirection(m_systemLayoutDirection);
+    Settings::setAllowsAnySSLCertificate(false);
 }
 
 class InternalSettingsWrapper : public Supplement<Page> {
@@ -618,6 +619,11 @@
     ec = INVALID_ACCESS_ERR;
 }
 
+void InternalSettings::setAllowsAnySSLCertificate(bool allowsAnyCertificate)
+{
+    Settings::setAllowsAnySSLCertificate(allowsAnyCertificate);
+}
+
 // If you add to this list, make sure that you update the Backup class for test reproducability!
 
 }

Modified: trunk/Source/WebCore/testing/InternalSettings.h (201403 => 201404)


--- trunk/Source/WebCore/testing/InternalSettings.h	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/testing/InternalSettings.h	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2012 Google Inc. All rights reserved.
- * Copyright (C) 2013, 2014, 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -163,6 +163,8 @@
     String systemLayoutDirection(ExceptionCode&);
     void setSystemLayoutDirection(const String& direction, ExceptionCode&);
 
+    static void setAllowsAnySSLCertificate(bool);
+
 private:
     explicit InternalSettings(Page*);
 

Modified: trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp (201403 => 201404)


--- trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/testing/js/WebCoreTestSupport.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -113,4 +114,9 @@
 #endif
 }
 
+void setAllowsAnySSLCertificate(bool allowAnySSLCertificate)
+{
+    InternalSettings::setAllowsAnySSLCertificate(allowAnySSLCertificate);
 }
+
+}

Modified: trunk/Source/WebCore/testing/js/WebCoreTestSupport.h (201403 => 201404)


--- trunk/Source/WebCore/testing/js/WebCoreTestSupport.h	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Source/WebCore/testing/js/WebCoreTestSupport.h	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2011, 2015 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,6 +54,7 @@
 
 void setLogChannelToAccumulate(const WTF::String& name) TEST_SUPPORT_EXPORT;
 void initializeLoggingChannelsIfNecessary() TEST_SUPPORT_EXPORT;
+void setAllowsAnySSLCertificate(bool) TEST_SUPPORT_EXPORT;
 
 } // namespace WebCore
 

Modified: trunk/Tools/ChangeLog (201403 => 201404)


--- trunk/Tools/ChangeLog	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/ChangeLog	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,3 +1,48 @@
+2016-05-25  Daniel Bates  <[email protected]> and Brent Fulgham  <[email protected]>
+
+        [WebSockets] No infrastructure for testing secure web sockets (wss)
+        https://bugs.webkit.org/show_bug.cgi?id=157884
+        <rdar://problem/26477197>
+
+        Reviewed by Andy Estes.
+
+        Add support to webkitpy to start and stop a secure Web Socket server running on port 9323
+        using the certificate, private-key from file LayoutTests/http/conf/webkit-httpd.pem. Also
+        teaches run-webkit-httpd to start and stop the Web Socket servers.
+
+        Modify DumpRenderTree and WebKitTestRunner to understand a new testRunner method,
+        'setAllowsAnySSLCertificate', which allows us to use the same self-signed test certificate
+        we do for our HTTPS tests.
+        
+        * DumpRenderTree/TestRunner.cpp:
+        (setAllowsAnySSLCertificateCallback):
+        (TestRunner::setAllowsAnySSLCertificate):
+        * DumpRenderTree/TestRunner.h:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebViewToConsistentStateBeforeTesting): Make sure we turn off the new flag between tests.
+        * Scripts/run-webkit-httpd:
+        (main): Start the websocket server at launch.
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager.__init__): Remove dead code.
+        * Scripts/webkitpy/layout_tests/servers/websocket_server.py:
+        (PyWebSocket.__init__): Cleanup code.
+        (PyWebSocket): Pass '--tls-client-ca' to start command.
+        (PyWebSocket._prepare_config): Cleanups.
+        * Scripts/webkitpy/port/base.py:
+        (Port.to.start_http_server):
+        (Port.to):
+        (Port.to._extract_certificate_from_pem): Added.
+        (Port.to._extract_private_key_from_pem): Added.
+        (Port.to.start_websocket_server): Start secure socket server.
+        (Port.to.stop_websocket_server): Stop secure socket server.
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: Add new API.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::setAllowsAnySSLCertificate): Added.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::setAllowsAnySSLCertificate): Added.
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+
 2016-05-25  Keith Miller  <[email protected]>
 
         run-jsc-benchmarks should use the new JSBench rather than look for it in the config file.

Modified: trunk/Tools/DumpRenderTree/TestRunner.cpp (201403 => 201404)


--- trunk/Tools/DumpRenderTree/TestRunner.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/DumpRenderTree/TestRunner.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1183,6 +1183,15 @@
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setAllowsAnySSLCertificateCallback(JSContextRef context, JSObjectRef, JSObjectRef, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    bool allowAnyCertificate = false;
+    if (argumentCount == 1)
+        allowAnyCertificate = JSValueToBoolean(context, arguments[0]);
+    
+    TestRunner::setAllowsAnySSLCertificate(allowAnyCertificate);
+    return JSValueMakeUndefined(context);
+}
 
 static JSValueRef setAllowUniversalAccessFromFileURLsCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
@@ -2101,6 +2110,7 @@
         { "setAcceptsEditing", setAcceptsEditingCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAllowUniversalAccessFromFileURLs", setAllowUniversalAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAllowFileAccessFromFileURLs", setAllowFileAccessFromFileURLsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setAllowsAnySSLCertificate", setAllowsAnySSLCertificateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAlwaysAcceptCookies", setAlwaysAcceptCookiesCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAppCacheMaximumSize", setAppCacheMaximumSizeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setAudioResult", setAudioResultCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -2280,3 +2290,8 @@
 
     WebCoreTestSupport::setLogChannelToAccumulate({ buffer.get() });
 }
+
+void TestRunner::setAllowsAnySSLCertificate(bool allowsAnySSLCertificate)
+{
+    WebCoreTestSupport::setAllowsAnySSLCertificate(allowsAnySSLCertificate);
+}

Modified: trunk/Tools/DumpRenderTree/TestRunner.h (201403 => 201404)


--- trunk/Tools/DumpRenderTree/TestRunner.h	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/DumpRenderTree/TestRunner.h	2016-05-25 21:58:08 UTC (rev 201404)
@@ -127,6 +127,8 @@
     void setPageVisibility(const char*);
     void resetPageVisibility();
 
+    static void setAllowsAnySSLCertificate(bool);
+
     void waitForPolicyDelegate();
     size_t webHistoryItemCount();
     int windowCount();

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (201403 => 201404)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1846,6 +1846,7 @@
     resetWebPreferencesToConsistentValues();
 
     TestRunner::setSerializeHTTPLoads(false);
+    TestRunner::setAllowsAnySSLCertificate(false);
 
     setlocale(LC_ALL, "");
 

Modified: trunk/Tools/Scripts/run-webkit-httpd (201403 => 201404)


--- trunk/Tools/Scripts/run-webkit-httpd	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/Scripts/run-webkit-httpd	2016-05-25 21:58:08 UTC (rev 201404)
@@ -66,12 +66,14 @@
         print "Starting httpd on <http://127.0.0.1:%s>" % http_port
 
     port.start_http_server()
+    port.start_websocket_server()
 
     try:
         tail = subprocess.Popen(['tail', '-F', log_file.name], stdout=subprocess.PIPE)
         while True:
             sys.stdout.write(tail.stdout.readline())
     except KeyboardInterrupt:
+        port.stop_websocket_server()
         port.stop_http_server()
 
 if __name__ == '__main__':

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (201403 => 201404)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2016-05-25 21:58:08 UTC (rev 201404)
@@ -78,16 +78,10 @@
         self._options = options
         self._printer = printer
         self._expectations = None
-
         self.HTTP_SUBDIR = 'http' + port.TEST_PATH_SEPARATOR
         self.WEBSOCKET_SUBDIR = 'websocket' + port.TEST_PATH_SEPARATOR
         self.web_platform_test_subdir = self._port.web_platform_test_server_doc_root()
         self.LAYOUT_TESTS_DIRECTORY = 'LayoutTests'
-
-        # disable wss server. need to install pyOpenSSL on buildbots.
-        # self._websocket_secure_server = websocket_server.PyWebSocket(
-        #        options.results_directory, use_tls=True, port=9323)
-
         self._results_directory = self._port.results_directory()
         self._finder = LayoutTestFinder(self._port, self._options)
         self._runner = LayoutTestRunner(self._options, self._port, self._printer, self._results_directory, self._test_is_slow)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/servers/websocket_server.py (201403 => 201404)


--- trunk/Tools/Scripts/webkitpy/layout_tests/servers/websocket_server.py	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/servers/websocket_server.py	2016-05-25 21:58:08 UTC (rev 201404)
@@ -1,4 +1,5 @@
 # Copyright (C) 2011 Google Inc. All rights reserved.
+# Copyright (C) 2016 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
@@ -39,8 +40,8 @@
 _log = logging.getLogger(__name__)
 
 
-_WS_LOG_PREFIX = 'pywebsocket.ws.log-'
-_WSS_LOG_PREFIX = 'pywebsocket.wss.log-'
+_WS_LOG_NAME = 'pywebsocket.ws.log'
+_WSS_LOG_NAME = 'pywebsocket.wss.log'
 
 
 _DEFAULT_WS_PORT = 8880
@@ -102,13 +103,12 @@
                 self._web_socket_tests = None
 
         if self._use_tls:
-            self._log_prefix = _WSS_LOG_PREFIX
+            self._log_prefix = _WSS_LOG_NAME
         else:
-            self._log_prefix = _WS_LOG_PREFIX
+            self._log_prefix = _WS_LOG_NAME
 
     def _prepare_config(self):
-        time_str = time.strftime('%d%b%Y-%H%M%S')
-        log_file_name = self._log_prefix + time_str
+        log_file_name = self._log_prefix
         # FIXME: Doesn't Executive have a devnull, so that we don't have to use os.devnull directly?
         self._wsin = open(os.devnull, 'r')
 
@@ -145,7 +145,7 @@
             start_cmd.extend(['-t', '-k', self._private_key,
                               '-c', self._certificate])
             if self._ca_certificate:
-                start_cmd.append('--ca-certificate')
+                start_cmd.append('--tls-client-ca')
                 start_cmd.append(self._ca_certificate)
 
         self._start_cmd = start_cmd

Modified: trunk/Tools/Scripts/webkitpy/port/base.py (201403 => 201404)


--- trunk/Tools/Scripts/webkitpy/port/base.py	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/Scripts/webkitpy/port/base.py	2016-05-25 21:58:08 UTC (rev 201404)
@@ -918,6 +918,12 @@
         server.start()
         self._http_server = server
 
+    def _extract_certificate_from_pem(self, pem_file, destination_certificate_file):
+        return self._executive.run_command(['openssl', 'x509', '-outform', 'pem', '-in', pem_file, '-out', destination_certificate_file], return_exit_code=True) == 0
+
+    def _extract_private_key_from_pem(self, pem_file, destination_private_key_file):
+        return self._executive.run_command(['openssl', 'rsa', '-in', pem_file, '-out', destination_private_key_file], return_exit_code=True) == 0
+
     def start_websocket_server(self):
         """Start a web server. Raise an error if it can't start or is already running.
 
@@ -928,6 +934,17 @@
         server.start()
         self._websocket_server = server
 
+        pem_file = self._filesystem.join(self.layout_tests_dir(), "http", "conf", "webkit-httpd.pem")
+        websocket_server_temporary_directory = self._filesystem.mkdtemp(prefix='webkitpy-websocket-server')
+        certificate_file = self._filesystem.join(str(websocket_server_temporary_directory), 'webkit-httpd.crt')
+        private_key_file = self._filesystem.join(str(websocket_server_temporary_directory), 'webkit-httpd.key')
+        self._websocket_server_temporary_directory = websocket_server_temporary_directory
+        if self._extract_certificate_from_pem(pem_file, certificate_file) and self._extract_private_key_from_pem(pem_file, private_key_file):
+            secure_server = self._websocket_secure_server = websocket_server.PyWebSocket(self, self.results_directory(),
+                                use_tls=True, port=9323, private_key=private_key_file, certificate=certificate_file)
+            secure_server.start()
+            self._websocket_secure_server = secure_server
+
     def start_web_platform_test_server(self, additional_dirs=None, number_of_servers=None):
         assert not self._web_platform_test_server, 'Already running a Web Platform Test server.'
 
@@ -964,6 +981,11 @@
         if self._websocket_server:
             self._websocket_server.stop()
             self._websocket_server = None
+        if self._websocket_secure_server:
+            self._websocket_secure_server.stop()
+            self._websocket_secure_server = None
+        if self._websocket_server_temporary_directory:
+            self._filesystem.rmtree(str(self._websocket_server_temporary_directory))
 
     def stop_web_platform_test_server(self):
         if self._web_platform_test_server:

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (201403 => 201404)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2016-05-25 21:58:08 UTC (rev 201404)
@@ -202,6 +202,8 @@
     void setAuthenticationUsername(DOMString username);
     void setAuthenticationPassword(DOMString password);
 
+    void setAllowsAnySSLCertificate(boolean value);
+
     // Secure text input mode (Mac only)
     readonly attribute boolean secureEventInputIsEnabled;
     

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (201403 => 201404)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -29,6 +29,7 @@
 #include "ActivateFonts.h"
 #include "InjectedBundlePage.h"
 #include "StringFunctions.h"
+#include "WebCoreTestSupport.h"
 #include <WebKit/WKBundle.h>
 #include <WebKit/WKBundlePage.h>
 #include <WebKit/WKBundlePagePrivate.h>
@@ -736,4 +737,9 @@
     return m_allowedHosts.contains(toWTFString(host));
 }
 
+void InjectedBundle::setAllowsAnySSLCertificate(bool allowsAnySSLCertificate)
+{
+    WebCoreTestSupport::setAllowsAnySSLCertificate(allowsAnySSLCertificate);
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (201403 => 201404)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2016-05-25 21:58:08 UTC (rev 201404)
@@ -123,6 +123,8 @@
 
     unsigned imageCountInGeneralPasteboard() const;
 
+    void setAllowsAnySSLCertificate(bool);
+    
 private:
     InjectedBundle();
     ~InjectedBundle();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (201403 => 201404)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2016-05-25 21:58:08 UTC (rev 201404)
@@ -369,6 +369,11 @@
     WKBundleOverrideBoolPreferenceForTestRunner(injectedBundle.bundle(), injectedBundle.pageGroup(), key.get(), enabled);
 }
 
+void TestRunner::setAllowsAnySSLCertificate(bool enabled)
+{
+    InjectedBundle::singleton().setAllowsAnySSLCertificate(enabled);
+}
+
 void TestRunner::setAllowUniversalAccessFromFileURLs(bool enabled)
 {
     auto& injectedBundle = InjectedBundle::singleton();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (201403 => 201404)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2016-05-25 21:57:03 UTC (rev 201403)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2016-05-25 21:58:08 UTC (rev 201404)
@@ -123,6 +123,7 @@
     void setCacheModel(int);
     void setAsynchronousSpellCheckingEnabled(bool);
     void setDownloadAttributeEnabled(bool);
+    void setAllowsAnySSLCertificate(bool);
 
     // Special DOM functions.
     void clearBackForwardList();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to