| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 try: | 204 try: |
| 205 converter.feed(test_content[1]) | 205 converter.feed(test_content[1]) |
| 206 converter.close() | 206 converter.close() |
| 207 converted = converter.output() | 207 converted = converter.output() |
| 208 finally: | 208 finally: |
| 209 oc.restore_output() | 209 oc.restore_output() |
| 210 | 210 |
| 211 self.verify_conversion_happened(converted) | 211 self.verify_conversion_happened(converted) |
| 212 self.verify_prefixed_properties(converted, test_content[0]) | 212 self.verify_prefixed_properties(converted, test_content[0]) |
| 213 | 213 |
| 214 def test_hides_all_instructions_for_manual_testers(self): | |
| 215 test_html = """<body> | |
| 216 <h1 class="instructions">Hello manual tester!</h1> | |
| 217 <p class="instructions some_other_class">This is how you run this test.</p> | |
| 218 <p style="willbeoverwritten" class="instructions">...</p> | |
| 219 <doesntmatterwhichtagitis class="some_other_class instructions">...</p> | |
| 220 <p>Legit content may contain the instructions string</p> | |
| 221 </body> | |
| 222 """ | |
| 223 expected_test_html = """<body> | |
| 224 <h1 class="instructions" style="display:none">Hello manual tester!</h1> | |
| 225 <p class="instructions some_other_class" style="display:none">This is how you ru
n this test.</p> | |
| 226 <p class="instructions" style="display:none">...</p> | |
| 227 <doesntmatterwhichtagitis class="some_other_class instructions" style="display:n
one">...</p> | |
| 228 <p>Legit content may contain the instructions string</p> | |
| 229 </body> | |
| 230 """ | |
| 231 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | |
| 232 | |
| 233 oc = OutputCapture() | |
| 234 oc.capture_output() | |
| 235 try: | |
| 236 converter.feed(test_html) | |
| 237 converter.close() | |
| 238 converted = converter.output() | |
| 239 finally: | |
| 240 oc.restore_output() | |
| 241 | |
| 242 self.assertEqual(converted[1], expected_test_html) | |
| 243 | |
| 244 def test_convert_attributes_if_needed(self): | 214 def test_convert_attributes_if_needed(self): |
| 245 """Tests convert_attributes_if_needed() using a reference file that has
some relative src paths.""" | 215 """Tests convert_attributes_if_needed() using a reference file that has
some relative src paths.""" |
| 246 | 216 |
| 247 test_html = """<html> | 217 test_html = """<html> |
| 248 <head> | 218 <head> |
| 249 <script src="../../some-script.js"></script> | 219 <script src="../../some-script.js"></script> |
| 250 <style src="../../../some-style.css"></style> | 220 <style src="../../../some-style.css"></style> |
| 251 </head> | 221 </head> |
| 252 <body> | 222 <body> |
| 253 <img src="../../../../some-image.jpg"> | 223 <img src="../../../../some-image.jpg"> |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 test_html = """<FONT></FONT>""" | 298 test_html = """<FONT></FONT>""" |
| 329 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | 299 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) |
| 330 converter.feed(test_html) | 300 converter.feed(test_html) |
| 331 self.assertEqual(converter.output(), ([], """<FONT></FONT>""")) | 301 self.assertEqual(converter.output(), ([], """<FONT></FONT>""")) |
| 332 | 302 |
| 333 def test_for_comments(self): | 303 def test_for_comments(self): |
| 334 test_html = """<!--abc--><!-- foo -->""" | 304 test_html = """<!--abc--><!-- foo -->""" |
| 335 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) | 305 converter = _W3CTestConverter(DUMMY_PATH, DUMMY_FILENAME, None) |
| 336 converter.feed(test_html) | 306 converter.feed(test_html) |
| 337 self.assertEqual(converter.output(), ([], """<!--abc--><!-- foo -->""")) | 307 self.assertEqual(converter.output(), ([], """<!--abc--><!-- foo -->""")) |
| OLD | NEW |