Title: [174748] trunk/Tools
Revision
174748
Author
commit-qu...@webkit.org
Date
2014-10-15 17:13:17 -0700 (Wed, 15 Oct 2014)

Log Message

import-w3c-test rewrites relative src paths in ref files incorrectly
https://bugs.webkit.org/show_bug.cgi?id=137586

This patch fixes a bug in test_converter.py where src paths were getting
rewritten as ../../some-path instead of <script src=""
It also adds support for rewriting src paths in style  elements, which was
missing before and it adds tests for this case.

Patch by Rebecca Hauck <rha...@adobe.com> on 2014-10-15
Reviewed by Bem Jones-Bey.

* Scripts/webkitpy/w3c/test_converter.py:
(_W3CTestConverter.convert_attributes_if_needed):
* Scripts/webkitpy/w3c/test_converter_unittest.py:
(test_convert_attributes_if_needed):
(verify_reference_relative_paths):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (174747 => 174748)


--- trunk/Tools/ChangeLog	2014-10-16 00:09:57 UTC (rev 174747)
+++ trunk/Tools/ChangeLog	2014-10-16 00:13:17 UTC (rev 174748)
@@ -1,3 +1,21 @@
+2014-10-15  Rebecca Hauck  <rha...@adobe.com>
+
+        import-w3c-test rewrites relative src paths in ref files incorrectly
+        https://bugs.webkit.org/show_bug.cgi?id=137586
+
+        This patch fixes a bug in test_converter.py where src paths were getting 
+        rewritten as ../../some-path instead of <script src="" 
+        It also adds support for rewriting src paths in style  elements, which was 
+        missing before and it adds tests for this case.
+
+        Reviewed by Bem Jones-Bey.
+
+        * Scripts/webkitpy/w3c/test_converter.py:
+        (_W3CTestConverter.convert_attributes_if_needed):
+        * Scripts/webkitpy/w3c/test_converter_unittest.py:
+        (test_convert_attributes_if_needed):
+        (verify_reference_relative_paths):
+
 2014-10-15  Jake Nielsen  <jacob_niel...@apple.com>
 
         Add --json flag to test-webkitpy to emit JSON formatted test results

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_converter.py (174747 => 174748)


--- trunk/Tools/Scripts/webkitpy/w3c/test_converter.py	2014-10-16 00:09:57 UTC (rev 174747)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_converter.py	2014-10-16 00:13:17 UTC (rev 174748)
@@ -179,11 +179,12 @@
                 new_style = self.convert_style_data(attr[1])
                 converted = re.sub(attr[1], new_style, converted)
 
-        src_tags = ('script', 'img', 'frame', 'iframe', 'input', 'layer', 'textarea', 'video', 'audio')
+        src_tags = ('script', 'style', 'img', 'frame', 'iframe', 'input', 'layer', 'textarea', 'video', 'audio')
         if tag in src_tags and self.reference_support_info is not None and  self.reference_support_info != {}:
             for attr_name, attr_value in attrs:
                 if attr_name == 'src':
-                    converted = self.convert_reference_relpaths(attr_value)
+                    new_path = self.convert_reference_relpaths(attr_value)
+                    converted = re.sub(attr_value, new_path, converted)
 
         self.converted_data.append(converted)
 

Modified: trunk/Tools/Scripts/webkitpy/w3c/test_converter_unittest.py (174747 => 174748)


--- trunk/Tools/Scripts/webkitpy/w3c/test_converter_unittest.py	2014-10-16 00:09:57 UTC (rev 174747)
+++ trunk/Tools/Scripts/webkitpy/w3c/test_converter_unittest.py	2014-10-16 00:13:17 UTC (rev 174748)
@@ -289,6 +289,34 @@
         self.verify_prefixed_properties(converted, test_content[0])
         self.verify_prefixed_property_values(converted, test_content[1])
 
+    def test_convert_attributes_if_needed(self):
+        """ Tests convert_attributes_if_needed() using a reference file that has some relative src paths """
+
+        test_html = """<html>
+<head>
+<script src=""
+<style src=""
+</head>
+<body>
+<img src=""
+</body>
+</html>
+"""
+        test_reference_support_info = {'reference_relpath': '../', 'files': ['../../some-script.js', '../../../some-style.css', '../../../../some-image.jpg'], 'elements': ['script', 'style', 'img']}
+        converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, test_reference_support_info)
+
+        oc = OutputCapture()
+        oc.capture_output()
+        try:
+            converter.feed(test_html)
+            converter.close()
+            converted = converter.output()
+        finally:
+            oc.restore_output()
+
+        self.verify_conversion_happened(converted)
+        self.verify_reference_relative_paths(converted, test_reference_support_info)
+
     def verify_conversion_happened(self, converted):
         self.assertTrue(converted, "conversion didn't happen")
 
@@ -321,6 +349,15 @@
         for test_value in test_property_values:
             self.assertTrue((test_value in converted[2]), 'Property value ' + test_value + ' not found in converted doc')
 
+    def verify_reference_relative_paths(self, converted, reference_support_info):
+        idx = 0
+        for path in reference_support_info['files']:
+            expected_path = re.sub(reference_support_info['reference_relpath'], '', path, 1)
+            element = reference_support_info['elements'][idx]
+            expected_tag = '<' + element + ' src="" + expected_path + '\">'
+            self.assertTrue(expected_tag in converted[2], 'relative path ' + path + ' was not converted correcty')
+            idx += 1
+
     def generate_test_content_properties_and_values(self, full_property_list, fully_property_values_list, num_test_properties_and_values, html):
         """Inserts properties requiring a -webkit- prefix into the content, replacing \'@testXX@\' with a property and \'@propvalueXX@\' with a value."""
         test_content_properties = self.generate_test_content(full_property_list, num_test_properties_and_values, 'test', html)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to