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

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

Issue 2249493002: Fixes html inlining if external stylesheet has include directive (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added new test case Created 4 years, 4 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 ea76d3732e9f6f14d1ddc5099d59498074aa63fe..16674cfe237432ee3b8db55066381fdbe2da174b 100755
--- a/tools/grit/grit/format/html_inline_unittest.py
+++ b/tools/grit/grit/format/html_inline_unittest.py
@@ -179,6 +179,95 @@ class HtmlInlineUnittest(unittest.TestCase):
tmp_dir.CleanUp()
+ def testInlineCSSWithIncludeDirective(self):
+ '''Tests that include directive in external css files also inlined'''
+
+ files = {
+ 'index.html': '''
+ <html>
+ <head>
+ <link rel="stylesheet" href="foo.css">
+ </head>
+ </html>
+ ''',
+
+ 'foo.css': '''<include src="style.css">''',
+
+ 'style.css': '''
+ <include src="style2.css">
+ blink {
+ display: none;
+ }
+ ''',
+ 'style2.css': '''h1 {}''',
+ }
+
+ expected_inlined = '''
+ <html>
+ <head>
+ <style>
+ h1 {}
+ blink {
+ display: none;
+ }
+ </style>
+ </head>
+ </html>
+ '''
+
+ 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('index.html'), None)
+ resources = result.inlined_files
+ resources.add(tmp_dir.GetPath('index.html'))
+ self.failUnlessEqual(resources, source_resources)
+ self.failUnlessEqual(expected_inlined,
+ util.FixLineEnd(result.inlined_data, '\n'))
+
+ def testCssIncludedFileNames(self):
+ '''Tests that all included files from css are returned'''
+
+ files = {
+ 'index.html': '''
+ <!DOCTYPE HTML>
+ <html>
+ <head>
+ <link rel="stylesheet" href="test.css">
+ </head>
+ <body>
+ </body>
+ </html>
+ ''',
+
+ 'test.css': '''
+ <include src="test2.css">
+ ''',
+
+ 'test2.css': '''
+ <include src="test3.css">
+ .image {
+ background: url('test.png');
+ }
+ ''',
+
+ 'test3.css': '''h1 {}''',
+
+ 'test.png': 'PNG DATA'
+ }
+
+ source_resources = set()
+ tmp_dir = util.TempDir(files)
+ for filename in files:
+ source_resources.add(tmp_dir.GetPath(filename))
+
+ resources = html_inline.GetResourceFilenames(tmp_dir.GetPath('index.html'))
+ resources.add(tmp_dir.GetPath('index.html'))
+ self.failUnlessEqual(resources, source_resources)
+ tmp_dir.CleanUp()
+
def testInlineCSSLinks(self):
'''Tests that only CSS files referenced via relative URLs are inlined.'''
« 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