Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import html_checker | 6 import html_checker |
| 7 from os import path as os_path | 7 from os import path as os_path |
| 8 import re | 8 import re |
| 9 from sys import path as sys_path | 9 from sys import path as sys_path |
| 10 import test_util | 10 import test_util |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 | 49 |
| 50 def testClassesUseDashFormCheckPasses(self): | 50 def testClassesUseDashFormCheckPasses(self): |
| 51 lines = [ | 51 lines = [ |
| 52 ' class="abc" ', | 52 ' class="abc" ', |
| 53 'class="foo-bar"', | 53 'class="foo-bar"', |
| 54 '<div class="foo-bar" id="classBar"', | 54 '<div class="foo-bar" id="classBar"', |
| 55 ] | 55 ] |
| 56 for line in lines: | 56 for line in lines: |
| 57 self.ShouldPassCheck(line, self.checker.ClassesUseDashFormCheck) | 57 self.ShouldPassCheck(line, self.checker.ClassesUseDashFormCheck) |
| 58 | 58 |
| 59 def testSingleQuoteCheckFails(self): | |
| 60 lines = [ | |
| 61 """ <a href='classBar'> """, | |
| 62 """<a foo$="bar" href$='classBar'>""", | |
| 63 """<a foo="bar" less="more" href='classBar' kittens="cats">""", | |
| 64 """<a cats href='classBar' dogs>""", | |
| 65 """<a cats\n href='classBar'\n dogs>""", | |
|
Dan Beam
2016/06/25 00:49:03
"""<a cats href='classBat\nclassBaz' dogs>"""
dschuyler
2016/06/28 19:04:18
Done.
| |
| 66 ] | |
| 67 for line in lines: | |
| 68 self.ShouldFailCheck(line, self.checker.DoNotUseSingleQuotesCheck) | |
| 69 | |
| 70 def testSingleQuoteCheckPasses(self): | |
| 71 lines = [ | |
| 72 """<b id="super-valid">SO VALID!</b>""", | |
| 73 """<a text$="i ain't got invalid quotes">i don't</a>""", | |
| 74 """<span>[[i18n('blah')]]</span> """, | |
| 75 """<a cats href="classBar" dogs>""", | |
| 76 """<a cats\n href="classBar"\n dogs>""", | |
| 77 ] | |
| 78 for line in lines: | |
| 79 self.ShouldPassCheck(line, self.checker.DoNotUseSingleQuotesCheck) | |
| 80 | |
| 59 def testDoNotCloseSingleTagsCheckFails(self): | 81 def testDoNotCloseSingleTagsCheckFails(self): |
| 60 lines = [ | 82 lines = [ |
| 61 "<input/>", | 83 "<input/>", |
| 62 ' <input id="a" /> ', | 84 ' <input id="a" /> ', |
| 63 "<div/>", | 85 "<div/>", |
| 64 "<br/>", | 86 "<br/>", |
| 65 "<br />", | 87 "<br />", |
| 66 ] | 88 ] |
| 67 for line in lines: | 89 for line in lines: |
| 68 self.ShouldFailCheck(line, self.checker.DoNotCloseSingleTagsCheck) | 90 self.ShouldFailCheck(line, self.checker.DoNotCloseSingleTagsCheck) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 ' my-for="abc" ', | 183 ' my-for="abc" ', |
| 162 ' myfor="abc" ', | 184 ' myfor="abc" ', |
| 163 " <for", | 185 " <for", |
| 164 ] | 186 ] |
| 165 for line in lines: | 187 for line in lines: |
| 166 self.ShouldPassCheck(line, self.checker.LabelCheck) | 188 self.ShouldPassCheck(line, self.checker.LabelCheck) |
| 167 | 189 |
| 168 | 190 |
| 169 if __name__ == '__main__': | 191 if __name__ == '__main__': |
| 170 unittest.main() | 192 unittest.main() |
| OLD | NEW |