Changeset 174672 in webkit
- Timestamp:
- Oct 14, 2014, 1:08:05 AM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r174667 r174672 1 2014-10-14 Manuel Rego Casasnovas <rego@igalia.com> 2 3 import-w3c-tests doesn't prefix property values 4 https://bugs.webkit.org/show_bug.cgi?id=137600 5 6 Reviewed by Bem Jones-Bey. 7 8 Some property values are prefixed in WebKit. Modified the W3C import 9 script in order to prefix property values and not only properties. 10 The patch re-uses most of the already existent logic to prefix 11 properties. 12 13 * Scripts/webkitpy/w3c/test_converter.py: Read prefixed property values 14 from CSSValueKeywords.in and adapt converter to modify both properties 15 and property values. 16 (convert_for_webkit): 17 (_W3CTestConverter.__init__): 18 (_W3CTestConverter.output): 19 (_W3CTestConverter.read_webkit_prefixed_css_property_list): 20 (_W3CTestConverter): 21 (_W3CTestConverter.add_webkit_prefix_to_unprefixed_properties_and_values): 22 (_W3CTestConverter.add_webkit_prefix_following_regex): 23 (_W3CTestConverter.convert_reference_relpaths): 24 (_W3CTestConverter.convert_style_data): 25 (_W3CTestConverter.convert_attributes_if_needed): 26 (_W3CTestConverter.add_webkit_prefix_to_unprefixed_properties): Deleted. 27 * Scripts/webkitpy/w3c/test_converter_unittest.py: Updated unit test to 28 include checks for property values too. 29 (W3CTestConverterTest.test_read_prefixed_property_list): 30 (verify_no_conversion_happened): 31 (verify_prefixed_properties): 32 (verify_prefixed_property_values): 33 (generate_test_content_properties_and_values): 34 (generate_test_content): 35 * Scripts/webkitpy/w3c/test_importer.py: Modified importer to manage 36 prefixed property values and inform about them. 37 (TestImporter.import_tests): 38 (TestImporter.write_import_log): 39 1 40 2014-10-13 Jer Noble <jer.noble@apple.com> 2 41 -
trunk/Tools/Scripts/webkitpy/w3c/test_converter.py
r173498 r174672 45 45 converter = _W3CTestConverter(new_path, filename, reference_support_info, host) 46 46 if filename.endswith('.css'): 47 return converter.add_webkit_prefix_to_unprefixed_properties (contents)47 return converter.add_webkit_prefix_to_unprefixed_properties_and_values(contents) 48 48 else: 49 49 converter.feed(contents) … … 62 62 self.converted_data = [] 63 63 self.converted_properties = [] 64 self.converted_property_values = [] 64 65 self.in_style_tag = False 65 66 self.style_data = [] … … 73 74 # These settings might vary between WebKit and Blink 74 75 self._css_property_file = self.path_from_webkit_root('Source', 'WebCore', 'css', 'CSSPropertyNames.in') 76 self._css_property_value_file = self.path_from_webkit_root('Source', 'WebCore', 'css', 'CSSValueKeywords.in') 75 77 self._css_property_split_string = '=' 76 78 77 79 self.test_harness_re = re.compile('/resources/testharness') 78 80 79 self.prefixed_properties = self.read_webkit_prefixed_css_property_list( )81 self.prefixed_properties = self.read_webkit_prefixed_css_property_list(self._css_property_file) 80 82 prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for prop in self.prefixed_properties) + ')(\s+:|:)' 81 83 self.prop_re = re.compile(prop_regex) 82 84 85 self.prefixed_property_values = self.read_webkit_prefixed_css_property_list(self._css_property_value_file) 86 prop_value_regex = '(:\s*|^\s*)(' + "|".join(value.replace('-webkit-', '') for value in self.prefixed_property_values) + ')(\s*;|\s*}|\s*$)' 87 self.prop_value_re = re.compile(prop_value_regex) 88 83 89 def output(self): 84 return (self.converted_properties, ''.join(self.converted_data))90 return (self.converted_properties, self.converted_property_values, ''.join(self.converted_data)) 85 91 86 92 def path_from_webkit_root(self, *comps): 87 93 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps)) 88 94 89 def read_webkit_prefixed_css_property_list(self): 95 def read_webkit_prefixed_css_property_list(self, file_name): 96 contents = self._filesystem.read_text_file(file_name) 90 97 prefixed_properties = [] 91 98 unprefixed_properties = set() 92 99 93 contents = self._filesystem.read_text_file(self._css_property_file)94 100 for line in contents.splitlines(): 95 101 if re.match('^(#|//)', line): … … 108 114 return [prop for prop in prefixed_properties if prop not in unprefixed_properties] 109 115 110 def add_webkit_prefix_to_unprefixed_properties(self, text): 111 """ Searches |text| for instances of properties requiring the -webkit- prefix and adds the prefix to them. 112 113 Returns the list of converted properties and the modified text.""" 114 115 converted_properties = set() 116 def add_webkit_prefix_to_unprefixed_properties_and_values(self, text): 117 """ Searches |text| for instances of properties and values requiring the -webkit- prefix and adds the prefix to them. 118 119 Returns the list of converted properties, values and the modified text.""" 120 121 converted_properties = self.add_webkit_prefix_following_regex(text, self.prop_re) 122 converted_property_values = self.add_webkit_prefix_following_regex(converted_properties[1], self.prop_value_re) 123 124 # FIXME: Handle the JS versions of these properties and values and GetComputedStyle, too. 125 return (converted_properties[0], converted_property_values[0], converted_property_values[1]) 126 127 def add_webkit_prefix_following_regex(self, text, regex): 128 converted_list = set() 116 129 text_chunks = [] 117 130 cur_pos = 0 118 for m in self.prop_re.finditer(text):131 for m in regex.finditer(text): 119 132 text_chunks.extend([text[cur_pos:m.start()], m.group(1), '-webkit-', m.group(2), m.group(3)]) 120 converted_ properties.add(m.group(2))133 converted_list.add(m.group(2)) 121 134 cur_pos = m.end() 122 135 text_chunks.append(text[cur_pos:]) 123 136 124 for prop in converted_properties: 125 _log.info(' converting %s', prop) 126 127 # FIXME: Handle the JS versions of these properties and GetComputedStyle, too. 128 return (converted_properties, ''.join(text_chunks)) 137 for item in converted_list: 138 _log.info(' converting %s', item) 139 140 return (converted_list, ''.join(text_chunks)) 129 141 130 142 def convert_reference_relpaths(self, text): … … 141 153 142 154 def convert_style_data(self, data): 143 converted = self.add_webkit_prefix_to_unprefixed_properties (data)155 converted = self.add_webkit_prefix_to_unprefixed_properties_and_values(data) 144 156 if converted[0]: 145 157 self.converted_properties.extend(list(converted[0])) 158 if converted[1]: 159 self.converted_property_values.extend(list(converted[1])) 146 160 147 161 if self.reference_support_info is None or self.reference_support_info == {}: 148 return converted[ 1]149 150 return self.convert_reference_relpaths(converted[ 1])162 return converted[2] 163 164 return self.convert_reference_relpaths(converted[2]) 151 165 152 166 def convert_attributes_if_needed(self, tag, attrs): -
trunk/Tools/Scripts/webkitpy/w3c/test_converter_unittest.py
r174136 r174672 55 55 prop_list = converter.prefixed_properties 56 56 self.assertTrue(prop_list, 'No prefixed properties found') 57 property_values_list = converter.prefixed_property_values 58 self.assertTrue(property_values_list, 'No prefixed property values found') 57 59 58 60 def test_convert_for_webkit_nothing_to_convert(self): … … 105 107 106 108 self.verify_conversion_happened(converted) 107 self.verify_test_harness_paths(converter, converted[ 1], fake_dir_path, 1, 1)109 self.verify_test_harness_paths(converter, converted[2], fake_dir_path, 1, 1) 108 110 self.verify_prefixed_properties(converted, []) 111 self.verify_prefixed_property_values(converted, []) 109 112 110 113 def test_convert_for_webkit_properties_only(self): … … 117 120 <style type="text/css"> 118 121 119 #block1 { @test0@: propvalue; }122 #block1 { @test0@: @propvalue0@; } 120 123 121 124 </style> 122 125 </head> 123 126 <body> 124 <div id="elem1" style="@test1@: propvalue;"></div>127 <div id="elem1" style="@test1@: @propvalue1@;"></div> 125 128 </body> 126 129 </html> … … 128 131 fake_dir_path = self.fake_dir_path('harnessandprops') 129 132 converter = _W3CTestConverter(fake_dir_path, DUMMY_FILENAME, None) 130 test_content = self.generate_test_content (converter.prefixed_properties, 1, test_html)131 132 oc = OutputCapture() 133 oc.capture_output() 134 try: 135 converter.feed(test_content[ 1])136 converter.close() 137 converted = converter.output() 138 finally: 139 oc.restore_output() 140 141 self.verify_conversion_happened(converted) 142 self.verify_test_harness_paths(converter, converted[ 1], fake_dir_path, 1, 1)133 test_content = self.generate_test_content_properties_and_values(converter.prefixed_properties, converter.prefixed_property_values, 1, test_html) 134 135 oc = OutputCapture() 136 oc.capture_output() 137 try: 138 converter.feed(test_content[2]) 139 converter.close() 140 converted = converter.output() 141 finally: 142 oc.restore_output() 143 144 self.verify_conversion_happened(converted) 145 self.verify_test_harness_paths(converter, converted[2], fake_dir_path, 1, 1) 143 146 self.verify_prefixed_properties(converted, test_content[0]) 147 self.verify_prefixed_property_values(converted, test_content[1]) 144 148 145 149 def test_convert_for_webkit_harness_and_properties(self): … … 152 156 <style type="text/css"> 153 157 154 #block1 { @test0@: propvalue; }155 #block2 { @test1@: propvalue; }156 #block3 { @test2@: propvalue; }158 #block1 { @test0@: @propvalue0@; } 159 #block2 { @test1@: @propvalue1@; } 160 #block3 { @test2@: @propvalue2@; } 157 161 158 162 </style> 159 163 </head> 160 164 <body> 161 <div id="elem1" style="@test3@: propvalue;"></div>165 <div id="elem1" style="@test3@: @propvalue3@;"></div> 162 166 </body> 163 167 </html> … … 169 173 oc.capture_output() 170 174 try: 171 test_content = self.generate_test_content (converter.prefixed_properties, 2, test_html)172 converter.feed(test_content[ 1])173 converter.close() 174 converted = converter.output() 175 finally: 176 oc.restore_output() 177 178 self.verify_conversion_happened(converted) 179 self.verify_test_harness_paths(converter, converted[ 1], fake_dir_path, 1, 1)175 test_content = self.generate_test_content_properties_and_values(converter.prefixed_properties, converter.prefixed_property_values, 2, test_html) 176 converter.feed(test_content[2]) 177 converter.close() 178 converted = converter.output() 179 finally: 180 oc.restore_output() 181 182 self.verify_conversion_happened(converted) 183 self.verify_test_harness_paths(converter, converted[2], fake_dir_path, 1, 1) 180 184 self.verify_prefixed_properties(converted, test_content[0]) 185 self.verify_prefixed_property_values(converted, test_content[1]) 181 186 182 187 def test_convert_test_harness_paths(self): … … 202 207 203 208 self.verify_conversion_happened(converted) 204 self.verify_test_harness_paths(converter, converted[ 1], fake_dir_path, 2, 1)209 self.verify_test_harness_paths(converter, converted[2], fake_dir_path, 2, 1) 205 210 206 211 def test_convert_prefixed_properties(self): … … 220 225 221 226 .block2 { 222 @test0@: propvalue;223 } 224 225 .block3{@test1@: propvalue;}226 227 .block4 { @test2@: propvalue; }228 229 .block5{ @test3@ : propvalue; }230 231 #block6 { @test4@ : propvalue; }227 @test0@: @propvalue0@; 228 } 229 230 .block3{@test1@: @propvalue1@;} 231 232 .block4 { @test2@:@propvalue2@; } 233 234 .block5{ @test3@ :@propvalue3@; } 235 236 #block6 { @test4@ : @propvalue4@ ; } 232 237 233 238 #block7 234 239 { 235 @test5@: propvalue;236 } 237 238 #block8 { @test6@: propvalue;}240 @test5@: @propvalue5@; 241 } 242 243 #block8 { @test6@: @propvalue6@ } 239 244 240 245 #block9:pseudo 241 246 { 242 247 243 @test7@: propvalue;248 @test7@: @propvalue7@; 244 249 @test8@: propvalue propvalue propvalue;; 250 propname: 251 @propvalue8@; 245 252 } 246 253 … … 248 255 </head> 249 256 <body> 250 <div id="elem1" style="@test9@: propvalue;"></div>251 <div id="elem2" style="propname: propvalue; @test10@ : propvalue; propname:propvalue;"></div>252 <div id="elem2" style="@test11@: propvalue; @test12@ : propvalue; @test13@ :propvalue;"></div>253 <div id="elem3" style="@test14@: propvalue"></div>257 <div id="elem1" style="@test9@: @propvalue9@;"></div> 258 <div id="elem2" style="propname: propvalue; @test10@ : @propvalue10@; propname:propvalue;"></div> 259 <div id="elem2" style="@test11@: @propvalue11@; @test12@ : @propvalue12@; @test13@ : @propvalue13@ ;"></div> 260 <div id="elem3" style="@test14@:@propvalue14@"></div> 254 261 </body> 255 262 <style type="text/css"><![CDATA[ 256 263 257 .block10{ @test15@: propvalue; }258 .block11{ @test16@: propvalue; }259 .block12{ @test17@: propvalue; }264 .block10{ @test15@: @propvalue15@; } 265 .block11{ @test16@: @propvalue16@; } 266 .block12{ @test17@: @propvalue17@; } 260 267 #block13:pseudo 261 268 { 262 @test18@: propvalue;263 @test19@: propvalue;269 @test18@: @propvalue18@; 270 @test19@: @propvalue19@; 264 271 } 265 272 … … 268 275 """ 269 276 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) 270 test_content = self.generate_test_content (converter.prefixed_properties, 20, test_html)271 272 oc = OutputCapture() 273 oc.capture_output() 274 try: 275 converter.feed(test_content[ 1])277 test_content = self.generate_test_content_properties_and_values(converter.prefixed_properties, converter.prefixed_property_values, 20, test_html) 278 279 oc = OutputCapture() 280 oc.capture_output() 281 try: 282 converter.feed(test_content[2]) 276 283 converter.close() 277 284 converted = converter.output() … … 281 288 self.verify_conversion_happened(converted) 282 289 self.verify_prefixed_properties(converted, test_content[0]) 290 self.verify_prefixed_property_values(converted, test_content[1]) 283 291 284 292 def verify_conversion_happened(self, converted): … … 286 294 287 295 def verify_no_conversion_happened(self, converted, original): 288 self.assertEqual(converted[ 1], original, 'test should not have been converted')296 self.assertEqual(converted[2], original, 'test should not have been converted') 289 297 290 298 def verify_test_harness_paths(self, converter, converted, test_path, num_src_paths, num_href_paths): … … 307 315 self.assertEqual(len(set(converted[0])), len(set(test_properties)), 'Incorrect number of properties converted') 308 316 for test_prop in test_properties: 309 self.assertTrue((test_prop in converted[1]), 'Property ' + test_prop + ' not found in converted doc') 310 311 def generate_test_content(self, full_property_list, num_test_properties, html): 312 """Inserts properties requiring a -webkit- prefix into the content, replacing \'@testXX@\' with a property.""" 313 test_properties = [] 317 self.assertTrue((test_prop in converted[2]), 'Property ' + test_prop + ' not found in converted doc') 318 319 def verify_prefixed_property_values(self, converted, test_property_values): 320 self.assertEqual(len(set(converted[1])), len(set(test_property_values)), 'Incorrect number of property values converted ' + str(len(set(converted[1]))) + ' vs ' + str(len(set(test_property_values)))) 321 for test_value in test_property_values: 322 self.assertTrue((test_value in converted[2]), 'Property value ' + test_value + ' not found in converted doc') 323 324 def generate_test_content_properties_and_values(self, full_property_list, fully_property_values_list, num_test_properties_and_values, html): 325 """Inserts properties requiring a -webkit- prefix into the content, replacing \'@testXX@\' with a property and \'@propvalueXX@\' with a value.""" 326 test_content_properties = self.generate_test_content(full_property_list, num_test_properties_and_values, 'test', html) 327 test_content_property_values = self.generate_test_content(fully_property_values_list, num_test_properties_and_values, 'propvalue', test_content_properties[1]) 328 return (test_content_properties[0], test_content_property_values[0], test_content_property_values[1]) 329 330 def generate_test_content(self, full_list, num_test, suffix, html): 331 test_list = [] 314 332 count = 0 315 while count < num_test _properties:316 test_ properties.append(full_property_list[count])333 while count < num_test: 334 test_list.append(full_list[count]) 317 335 count += 1 318 336 319 # Replace the tokens in the testhtml with the test properties . Walk backward320 # through the list to replace the double-digit tokens first321 index = len(test_ properties) - 1337 # Replace the tokens in the testhtml with the test properties or values. 338 # Walk backward through the list to replace the double-digit tokens first. 339 index = len(test_list) - 1 322 340 while index >= 0: 323 341 # Use the unprefixed version 324 test _prop = test_properties[index].replace('-webkit-', '')342 test = test_list[index].replace('-webkit-', '') 325 343 # Replace the token 326 html = html.replace('@ test' + str(index) + '@', test_prop)344 html = html.replace('@' + suffix + str(index) + '@', test) 327 345 index -= 1 328 346 329 return (test_ properties, html)347 return (test_list, html) -
trunk/Tools/Scripts/webkitpy/w3c/test_importer.py
r173876 r174672 240 240 total_imported_jstests = 0 241 241 total_prefixed_properties = {} 242 total_prefixed_property_values = {} 242 243 243 244 failed_conversion_files = [] … … 249 250 250 251 prefixed_properties = [] 252 prefixed_property_values = [] 251 253 252 254 if not dir_to_copy['copy_list']: … … 313 315 314 316 prefixed_properties.extend(set(converted_file[0]) - set(prefixed_properties)) 317 318 for prefixed_value in converted_file[1]: 319 total_prefixed_property_values.setdefault(prefixed_value, 0) 320 total_prefixed_property_values[prefixed_value] += 1 321 322 prefixed_property_values.extend(set(converted_file[1]) - set(prefixed_property_values)) 323 315 324 outfile = open(new_filepath, 'wb') 316 outfile.write(converted_file[ 1])325 outfile.write(converted_file[2]) 317 326 outfile.close() 318 327 else: … … 322 331 323 332 self.remove_deleted_files(new_path, copied_files) 324 self.write_import_log(new_path, copied_files, prefixed_properties )333 self.write_import_log(new_path, copied_files, prefixed_properties, prefixed_property_values) 325 334 326 335 _log.info('Import complete') … … 337 346 for prefixed_property in sorted(total_prefixed_properties, key=lambda p: total_prefixed_properties[p]): 338 347 _log.info(' %s: %s', prefixed_property, total_prefixed_properties[prefixed_property]) 348 _log.info('') 349 _log.info('Property values needing prefixes (by count):') 350 351 for prefixed_value in sorted(total_prefixed_property_values, key=lambda p: total_prefixed_property_values[p]): 352 _log.info(' %s: %s', prefixed_value, total_prefixed_property_values[prefixed_value]) 339 353 340 354 def remove_deleted_files(self, import_directory, new_file_list): … … 362 376 import_log.close() 363 377 364 def write_import_log(self, import_directory, file_list, prop_list ):378 def write_import_log(self, import_directory, file_list, prop_list, property_values_list): 365 379 """ Writes a w3c-import.log file in each directory with imported files. """ 366 380 … … 385 399 else: 386 400 import_log.write('None\n') 401 import_log.write('Property values requiring vendor prefixes:\n') 402 if property_values_list: 403 for value in property_values_list: 404 import_log.write(value + '\n') 405 else: 406 import_log.write('None\n') 387 407 import_log.write('------------------------------------------------------------------------\n') 388 408 import_log.write('List of files:\n')
Note:
See TracChangeset
for help on using the changeset viewer.