Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: Tools/Scripts/webkitpy/w3c/test_converter.py

Issue 353983003: Making it possible to import mediastream tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Setting execute bits on importer scripts. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 6 # modification, are permitted provided that the following conditions
7 # are met: 7 # are met:
8 # 8 #
9 # 1. Redistributions of source code must retain the above 9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 self._webkit_root = WebKitFinder(self._filesystem).webkit_base() 61 self._webkit_root = WebKitFinder(self._filesystem).webkit_base()
62 62
63 self.converted_data = [] 63 self.converted_data = []
64 self.converted_properties = [] 64 self.converted_properties = []
65 self.in_style_tag = False 65 self.in_style_tag = False
66 self.style_data = [] 66 self.style_data = []
67 self.filename = filename 67 self.filename = filename
68 68
69 resources_path = self.path_from_webkit_root('LayoutTests', 'resources') 69 resources_path = self.path_from_webkit_root('LayoutTests', 'resources')
70 resources_relpath = self._filesystem.relpath(resources_path, new_path) 70 resources_relpath = self._filesystem.relpath(resources_path, new_path)
71 self.new_test_harness_path = resources_relpath 71 self.resources_relpath = resources_relpath
72 72
73 # These settings might vary between WebKit and Blink 73 # These settings might vary between WebKit and Blink
74 self._css_property_file = self.path_from_webkit_root('Source', 'core', ' css', 'CSSPropertyNames.in') 74 self._css_property_file = self.path_from_webkit_root('Source', 'core', ' css', 'CSSPropertyNames.in')
75 self._css_property_split_string = 'alias_for=' 75 self._css_property_split_string = 'alias_for='
76 76
77 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() 77 self.prefixed_properties = self.read_webkit_prefixed_css_property_list()
78 78
79 self.test_harness_re = re.compile('/resources/testharness')
80
81 self.prefixed_properties = self.read_webkit_prefixed_css_property_list() 79 self.prefixed_properties = self.read_webkit_prefixed_css_property_list()
82 prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for pr op in self.prefixed_properties) + ')(\s+:|:)' 80 prop_regex = '([\s{]|^)(' + "|".join(prop.replace('-webkit-', '') for pr op in self.prefixed_properties) + ')(\s+:|:)'
83 self.prop_re = re.compile(prop_regex) 81 self.prop_re = re.compile(prop_regex)
84 82
85 def output(self): 83 def output(self):
86 return (self.converted_properties, ''.join(self.converted_data)) 84 return (self.converted_properties, ''.join(self.converted_data))
87 85
88 def path_from_webkit_root(self, *comps): 86 def path_from_webkit_root(self, *comps):
89 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps)) 87 return self._filesystem.abspath(self._filesystem.join(self._webkit_root, *comps))
90 88
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 129
132 def convert_style_data(self, data): 130 def convert_style_data(self, data):
133 converted = self.add_webkit_prefix_to_unprefixed_properties(data) 131 converted = self.add_webkit_prefix_to_unprefixed_properties(data)
134 if converted[0]: 132 if converted[0]:
135 self.converted_properties.extend(list(converted[0])) 133 self.converted_properties.extend(list(converted[0]))
136 return converted[1] 134 return converted[1]
137 135
138 def convert_attributes_if_needed(self, tag, attrs): 136 def convert_attributes_if_needed(self, tag, attrs):
139 converted = self.get_starttag_text() 137 converted = self.get_starttag_text()
140 if tag in ('script', 'link'): 138 if tag in ('script', 'link'):
141 attr_name = 'src' 139 target_attr = 'src'
142 if tag != 'script': 140 if tag != 'script':
143 attr_name = 'href' 141 target_attr = 'href'
144 for attr in attrs: 142 for attr_name, attr_value in attrs:
145 if attr[0] == attr_name: 143 if attr_name == target_attr:
146 new_path = re.sub(self.test_harness_re, self.new_test_harnes s_path + '/testharness', attr[1]) 144 new_path = re.sub('/resources/testharness',
147 converted = re.sub(attr[1], new_path, converted) 145 self.resources_relpath + '/testharness',
146 attr_value)
147 converted = re.sub(attr_value, new_path, converted)
148 new_path = re.sub('/common/vendor-prefix',
149 self.resources_relpath + '/vendor-prefix',
150 attr_value)
151 converted = re.sub(attr_value, new_path, converted)
148 152
149 for attr in attrs: 153 for attr_name, attr_value in attrs:
150 if attr[0] == 'style': 154 if attr_name == 'style':
151 new_style = self.convert_style_data(attr[1]) 155 new_style = self.convert_style_data(attr_value)
152 converted = re.sub(attr[1], new_style, converted) 156 converted = re.sub(attr_value, new_style, converted)
157 if attr_name == 'class' and 'instructions' in attr_value:
158 # Always hide instructions, they're for manual testers.
159 converted = re.sub(' style=".*?"', '', converted)
160 converted = re.sub('\>', ' style="display:none">', converted)
153 161
154 self.converted_data.append(converted) 162 self.converted_data.append(converted)
155 163
156 def handle_starttag(self, tag, attrs): 164 def handle_starttag(self, tag, attrs):
157 if tag == 'style': 165 if tag == 'style':
158 self.in_style_tag = True 166 self.in_style_tag = True
159 self.convert_attributes_if_needed(tag, attrs) 167 self.convert_attributes_if_needed(tag, attrs)
160 168
161 def handle_endtag(self, tag): 169 def handle_endtag(self, tag):
162 if tag == 'style': 170 if tag == 'style':
(...skipping 19 matching lines...) Expand all
182 190
183 def handle_comment(self, data): 191 def handle_comment(self, data):
184 self.converted_data.extend(['<!-- ', data, ' -->']) 192 self.converted_data.extend(['<!-- ', data, ' -->'])
185 193
186 def handle_decl(self, decl): 194 def handle_decl(self, decl):
187 self.converted_data.extend(['<!', decl, '>']) 195 self.converted_data.extend(['<!', decl, '>'])
188 196
189 def handle_pi(self, data): 197 def handle_pi(self, data):
190 self.converted_data.extend(['<?', data, '>']) 198 self.converted_data.extend(['<?', data, '>'])
191 199
OLDNEW
« no previous file with comments | « LayoutTests/resources/vendor-prefix.js ('k') | Tools/Scripts/webkitpy/w3c/test_converter_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698