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

Unified Diff: tools/grit/grit/format/html_inline_unittest.py

Issue 2615953002: Fix grit's <if> not to strip trailing or preceding whitespace (Closed)
Patch Set: indent tweak and comment fixes for thakis@ Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/grit/grit/format/html_inline.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/html_inline_unittest.py
diff --git a/tools/grit/grit/format/html_inline_unittest.py b/tools/grit/grit/format/html_inline_unittest.py
index c236f4f7483de356f6ff3bbe05baab63ba64d011..d049b1ef963cba46bc30d200a48fb01b3f80ee1a 100755
--- a/tools/grit/grit/format/html_inline_unittest.py
+++ b/tools/grit/grit/format/html_inline_unittest.py
@@ -444,5 +444,68 @@ class HtmlInlineUnittest(unittest.TestCase):
self.failUnlessEqual(expected_inlined,
util.FixLineEnd(result.inlined_data, '\n'))
+ def testCommentedJsInclude(self):
+ '''Tests that <include> works inside a comment.'''
+
+ files = {
+ 'include.js': '// <include src="other.js">',
+ 'other.js': '// Copyright somebody\nalert(1);',
+ }
+
+ expected_inlined = '// // Copyright somebody\nalert(1);'
+
+ source_resources = set()
+ tmp_dir = util.TempDir(files)
+ for filename in files:
+ source_resources.add(tmp_dir.GetPath(filename))
+
+ result = html_inline.DoInline(tmp_dir.GetPath('include.js'), None)
+ resources = result.inlined_files
+ resources.add(tmp_dir.GetPath('include.js'))
+ self.failUnlessEqual(resources, source_resources)
+ self.failUnlessEqual(expected_inlined,
+ util.FixLineEnd(result.inlined_data, '\n'))
+
+ def testCommentedJsIf(self):
+ '''Tests that <if> works inside a comment.'''
+
+ files = {
+ 'if.js': '''
+ // <if expr="True">
+ yep();
+ // </if>
+
+ // <if expr="False">
+ nope();
+ // </if>
+ ''',
+ }
+
+ expected_inlined = '''
+ //
+ yep();
+ //
+
+ //
+ '''
+
+ source_resources = set()
+ tmp_dir = util.TempDir(files)
+ for filename in files:
+ source_resources.add(tmp_dir.GetPath(filename))
+
+ class FakeGrdNode(object):
+ def EvaluateCondition(self, cond):
+ return eval(cond)
+
+ result = html_inline.DoInline(tmp_dir.GetPath('if.js'), FakeGrdNode())
+ resources = result.inlined_files
+
+ resources.add(tmp_dir.GetPath('if.js'))
+ self.failUnlessEqual(resources, source_resources)
+ self.failUnlessEqual(expected_inlined,
+ util.FixLineEnd(result.inlined_data, '\n'))
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tools/grit/grit/format/html_inline.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698