Title: [217902] trunk/Tools
Revision
217902
Author
dba...@webkit.org
Date
2017-06-07 13:25:22 -0700 (Wed, 07 Jun 2017)

Log Message

Teach run-webkit-tests how to run HTTPS Web Platform Tests
https://bugs.webkit.org/show_bug.cgi?id=172930
<rdar://problem/32570201>

Reviewed by Youenn Fablet.

Some web platform tests need to be run from an HTTPS server in order to exercise functionality
that is conditioned on the page being delivered over a secure protocol. One example of such
a test is LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/secure_context/crypto-subtle-secure-context-available.https.sub.html.

Ideally we should look to use wptrunner to run Web Platform Tests. For now, modify run-webkit-tests
to access web platform tests from an HTTPS server when the filename of the test contains ".https.".
This makes run-webkit-test match the behavior of wptrunner: <https://github.com/w3c/web-platform-tests/blob/7ce469d1c46dd45aacfe1b408bf2ad36a630e089/tools/manifest/item.py#L42>.

* Scripts/webkitpy/layout_tests/servers/web_platform_test_server.py:
(https_base_url): Parses the Web Platform Tests JSON configuration and returns the base URL
to the Web Platform Tests HTTPS server.
* Scripts/webkitpy/port/base.py:
(Port.to.web_platform_test_server_https_base_url): Turns around and calls https_base_url().
* Scripts/webkitpy/port/driver.py:
(Driver.__init__): Caches the base URL to the Web Platform Tests HTTPS server. Also rename
instance variables web_platform_test_server_doc_root, web_platform_test_server_base_url to
_web_platform_test_server_doc_root and _web_platform_test_server_base_url, respectively to
indicate that they should be considered private instance variables.
(Driver.is_web_platform_test): Update code for renamed instance variables.
(Driver):
(Driver._web_platform_test_base_url_for_test): Returns the URL to access the specified test.
(Driver.test_to_uri): Modified to use Driver._web_platform_test_base_url_for_test() to
determine the base URL to use to access the test.
(Driver.uri_to_test): Added logic to compute the filesystem local test name from a Web
Platform Tests HTTPS URL. Also updated code for renamed instance variables.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (217901 => 217902)


--- trunk/Tools/ChangeLog	2017-06-07 20:10:50 UTC (rev 217901)
+++ trunk/Tools/ChangeLog	2017-06-07 20:25:22 UTC (rev 217902)
@@ -1,3 +1,37 @@
+2017-06-07  Daniel Bates  <daba...@apple.com>
+
+        Teach run-webkit-tests how to run HTTPS Web Platform Tests
+        https://bugs.webkit.org/show_bug.cgi?id=172930
+        <rdar://problem/32570201>
+
+        Reviewed by Youenn Fablet.
+
+        Some web platform tests need to be run from an HTTPS server in order to exercise functionality
+        that is conditioned on the page being delivered over a secure protocol. One example of such
+        a test is LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/secure_context/crypto-subtle-secure-context-available.https.sub.html.
+
+        Ideally we should look to use wptrunner to run Web Platform Tests. For now, modify run-webkit-tests
+        to access web platform tests from an HTTPS server when the filename of the test contains ".https.".
+        This makes run-webkit-test match the behavior of wptrunner: <https://github.com/w3c/web-platform-tests/blob/7ce469d1c46dd45aacfe1b408bf2ad36a630e089/tools/manifest/item.py#L42>.
+
+        * Scripts/webkitpy/layout_tests/servers/web_platform_test_server.py:
+        (https_base_url): Parses the Web Platform Tests JSON configuration and returns the base URL
+        to the Web Platform Tests HTTPS server.
+        * Scripts/webkitpy/port/base.py:
+        (Port.to.web_platform_test_server_https_base_url): Turns around and calls https_base_url().
+        * Scripts/webkitpy/port/driver.py:
+        (Driver.__init__): Caches the base URL to the Web Platform Tests HTTPS server. Also rename
+        instance variables web_platform_test_server_doc_root, web_platform_test_server_base_url to
+        _web_platform_test_server_doc_root and _web_platform_test_server_base_url, respectively to
+        indicate that they should be considered private instance variables.
+        (Driver.is_web_platform_test): Update code for renamed instance variables.
+        (Driver):
+        (Driver._web_platform_test_base_url_for_test): Returns the URL to access the specified test.
+        (Driver.test_to_uri): Modified to use Driver._web_platform_test_base_url_for_test() to
+        determine the base URL to use to access the test.
+        (Driver.uri_to_test): Added logic to compute the filesystem local test name from a Web
+        Platform Tests HTTPS URL. Also updated code for renamed instance variables.
+
 2017-06-07  Per Arne Vollan  <pvol...@apple.com>
 
         Support removal of authentication data through the Website data store API.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/servers/web_platform_test_server.py (217901 => 217902)


--- trunk/Tools/Scripts/webkitpy/layout_tests/servers/web_platform_test_server.py	2017-06-07 20:10:50 UTC (rev 217901)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/servers/web_platform_test_server.py	2017-06-07 20:25:22 UTC (rev 217902)
@@ -55,6 +55,16 @@
     return "http://" + config["host"] + ":" + str(ports["http"][0]) + "/"
 
 
+def https_base_url(port_obj):
+    config = wpt_config_json(port_obj)
+    if not config:
+        # This should only be hit by webkitpy unit tests
+        _log.debug("No WPT config file found")
+        return "http://localhost:9443/"
+    ports = config["ports"]
+    return "https://" + config["host"] + ":" + str(ports["https"][0]) + "/"
+
+
 def is_wpt_server_running(port_obj):
     config = wpt_config_json(port_obj)
     if not config:

Modified: trunk/Tools/Scripts/webkitpy/port/base.py (217901 => 217902)


--- trunk/Tools/Scripts/webkitpy/port/base.py	2017-06-07 20:10:50 UTC (rev 217901)
+++ trunk/Tools/Scripts/webkitpy/port/base.py	2017-06-07 20:25:22 UTC (rev 217902)
@@ -1023,6 +1023,9 @@
     def web_platform_test_server_base_url(self):
         return web_platform_test_server.base_url(self)
 
+    def web_platform_test_server_https_base_url(self):
+        return web_platform_test_server.https_base_url(self)
+
     def http_server_supports_ipv6(self):
         # Cygwin is the only platform to still use Apache 1.3, which only supports IPV4.
         # Once it moves to Apache 2, we can drop this method altogether.

Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (217901 => 217902)


--- trunk/Tools/Scripts/webkitpy/port/driver.py	2017-06-07 20:10:50 UTC (rev 217901)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py	2017-06-07 20:25:22 UTC (rev 217902)
@@ -1,5 +1,5 @@
 # Copyright (C) 2011 Google Inc. All rights reserved.
-# Copyright (c) 2015, 2016 Apple Inc. All rights reserved.
+# Copyright (c) 2015-2017 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
@@ -166,8 +166,9 @@
         else:
             self._profiler = None
 
-        self.web_platform_test_server_doc_root = self._port.web_platform_test_server_doc_root()
-        self.web_platform_test_server_base_url = self._port.web_platform_test_server_base_url()
+        self._web_platform_test_server_doc_root = self._port.web_platform_test_server_doc_root()
+        self._web_platform_test_server_base_url = self._port.web_platform_test_server_base_url()
+        self._web_platform_test_server_https_base_url = self._port.web_platform_test_server_https_base_url()
 
     def __del__(self):
         self.stop()
@@ -264,14 +265,20 @@
         return test_name.startswith(self.WEBKIT_SPECIFIC_WEB_PLATFORM_TEST_SUBDIR)
 
     def is_web_platform_test(self, test_name):
-        return test_name.startswith(self.web_platform_test_server_doc_root)
+        return test_name.startswith(self._web_platform_test_server_doc_root)
 
+    def _web_platform_test_base_url_for_test(self, test_name):
+        needs_https_server = '.https.' in test_name
+        if needs_https_server:
+            return self._web_platform_test_server_https_base_url
+        return self._web_platform_test_server_base_url
+
     def test_to_uri(self, test_name):
         """Convert a test name to a URI."""
         if self.is_web_platform_test(test_name):
-            return self.web_platform_test_server_base_url + test_name[len(self.web_platform_test_server_doc_root):]
+            return self._web_platform_test_base_url_for_test(test_name) + test_name[len(self._web_platform_test_server_doc_root):]
         if self.is_webkit_specific_web_platform_test(test_name):
-            return self.web_platform_test_server_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE + test_name[len(self.WEBKIT_SPECIFIC_WEB_PLATFORM_TEST_SUBDIR):]
+            return self._web_platform_test_base_url_for_test(test_name) + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE + test_name[len(self.WEBKIT_SPECIFIC_WEB_PLATFORM_TEST_SUBDIR):]
 
         if not self.is_http_test(test_name):
             return path.abspath_to_uri(self._port.host.platform, self._port.abspath_for_test(test_name))
@@ -296,10 +303,14 @@
             if not prefix.endswith('/'):
                 prefix += '/'
             return uri[len(prefix):]
-        if uri.startswith(self.web_platform_test_server_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE):
-            return uri.replace(self.web_platform_test_server_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE, self.WEBKIT_SPECIFIC_WEB_PLATFORM_TEST_SUBDIR)
-        if uri.startswith(self.web_platform_test_server_base_url):
-            return uri.replace(self.web_platform_test_server_base_url, self.web_platform_test_server_doc_root)
+        if uri.startswith(self._web_platform_test_server_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE):
+            return uri.replace(self._web_platform_test_server_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE, self.WEBKIT_SPECIFIC_WEB_PLATFORM_TEST_SUBDIR)
+        if uri.startswith(self._web_platform_test_server_base_url):
+            return uri.replace(self._web_platform_test_server_base_url, self._web_platform_test_server_doc_root)
+        if uri.startswith(self._web_platform_test_server_https_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE):
+            return uri.replace(self._web_platform_test_server_https_base_url + self.WEBKIT_WEB_PLATFORM_TEST_SERVER_ROUTE, self.WEBKIT_SPECIFIC_WEB_PLATFORM_TEST_SUBDIR)
+        if uri.startswith(self._web_platform_test_server_https_base_url):
+            return uri.replace(self._web_platform_test_server_https_base_url, self._web_platform_test_server_doc_root)
         if uri.startswith("http://"):
             return uri.replace('http://127.0.0.1:8000/', self.HTTP_DIR)
         if uri.startswith("https://"):
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to