| OLD | NEW |
| 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 1 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
| 5 # are met: | 5 # are met: |
| 6 # | 6 # |
| 7 # 1. Redistributions of source code must retain the above | 7 # 1. Redistributions of source code must retain the above |
| 8 # copyright notice, this list of conditions and the following | 8 # copyright notice, this list of conditions and the following |
| 9 # disclaimer. | 9 # disclaimer. |
| 10 # 2. Redistributions in binary form must reproduce the above | 10 # 2. Redistributions in binary form must reproduce the above |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 """Converts a file's contents so the Blink layout test runner can run it. | 40 """Converts a file's contents so the Blink layout test runner can run it. |
| 41 | 41 |
| 42 Returns: | 42 Returns: |
| 43 A pair: the list of modified properties, and the modified text if the file
was modified, None otherwise. | 43 A pair: the list of modified properties, and the modified text if the file
was modified, None otherwise. |
| 44 """ | 44 """ |
| 45 contents = host.filesystem.read_binary_file(filename) | 45 contents = host.filesystem.read_binary_file(filename) |
| 46 converter = _W3CTestConverter(new_path, filename, reference_support_info, ho
st) | 46 converter = _W3CTestConverter(new_path, filename, reference_support_info, ho
st) |
| 47 if filename.endswith('.css'): | 47 if filename.endswith('.css'): |
| 48 return converter.add_webkit_prefix_to_unprefixed_properties(contents.dec
ode('utf-8')) | 48 return converter.add_webkit_prefix_to_unprefixed_properties(contents.dec
ode('utf-8')) |
| 49 else: | 49 else: |
| 50 converter.feed(contents.decode('utf-8')) | 50 try: |
| 51 converter.feed(contents.decode('utf-8')) |
| 52 except UnicodeDecodeError: |
| 53 converter.feed(contents.decode('utf-16')) |
| 51 converter.close() | 54 converter.close() |
| 52 return converter.output() | 55 return converter.output() |
| 53 | 56 |
| 54 | 57 |
| 55 class _W3CTestConverter(HTMLParser): | 58 class _W3CTestConverter(HTMLParser): |
| 56 """A HTMLParser subclass which converts a HTML file as it is parsed. | 59 """A HTMLParser subclass which converts a HTML file as it is parsed. |
| 57 | 60 |
| 58 After the feed() method is called, the converted document will be stored | 61 After the feed() method is called, the converted document will be stored |
| 59 in converted_data, and can be retrieved with the output() method. | 62 in converted_data, and can be retrieved with the output() method. |
| 60 """ | 63 """ |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 self.converted_data.extend(['&#', name, ';']) | 211 self.converted_data.extend(['&#', name, ';']) |
| 209 | 212 |
| 210 def handle_comment(self, data): | 213 def handle_comment(self, data): |
| 211 self.converted_data.extend(['<!-- ', data, ' -->']) | 214 self.converted_data.extend(['<!-- ', data, ' -->']) |
| 212 | 215 |
| 213 def handle_decl(self, decl): | 216 def handle_decl(self, decl): |
| 214 self.converted_data.extend(['<!', decl, '>']) | 217 self.converted_data.extend(['<!', decl, '>']) |
| 215 | 218 |
| 216 def handle_pi(self, data): | 219 def handle_pi(self, data): |
| 217 self.converted_data.extend(['<?', data, '>']) | 220 self.converted_data.extend(['<?', data, '>']) |
| OLD | NEW |