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

Unified Diff: grit/format/html_inline_unittest.py

Issue 12261055: Correctly resolve relative paths when inlining @import directives in CSS files. (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Created 7 years, 10 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 | « 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: grit/format/html_inline_unittest.py
diff --git a/grit/format/html_inline_unittest.py b/grit/format/html_inline_unittest.py
index 57efc4e21574dec8ae0955dcfa8f44b09bd70bd7..493ffc103651bc80fd6b3b79776a285859aab7cb 100755
--- a/grit/format/html_inline_unittest.py
+++ b/grit/format/html_inline_unittest.py
@@ -91,25 +91,25 @@ class HtmlInlineUnittest(unittest.TestCase):
'index.html': '''
<html>
<head>
- <link rel="stylesheet" href="test.css">
+ <link rel="stylesheet" href="css/test.css">
</head>
</html>
''',
- 'test.css': '''
- @import url('test2.css')
+ 'css/test.css': '''
+ @import url('test2.css');
blink {
display: none;
}
''',
- 'test2.css': '''
+ 'css/test2.css': '''
.image {
- background: url('test.png');
+ background: url('../images/test.png');
}
'''.strip(),
- 'test.png': 'PNG DATA'
+ 'images/test.png': 'PNG DATA'
}
expected_inlined = '''
@@ -140,6 +140,52 @@ class HtmlInlineUnittest(unittest.TestCase):
tmp_dir.CleanUp()
+ def testInlineCSSLinks(self):
+ '''Tests that only CSS files referenced via relative URLs are inlined.'''
+
+ files = {
+ 'index.html': '''
+ <html>
+ <head>
+ <link rel="stylesheet" href="foo.css">
+ <link rel="stylesheet" href="chrome://resources/bar.css">
+ </head>
+ </html>
+ ''',
+
+ 'foo.css': '''
+ @import url(chrome://resources/blurp.css);
+ blink {
+ display: none;
+ }
+ ''',
+ }
+
+ expected_inlined = '''
+ <html>
+ <head>
+ <style>
+ @import url(chrome://resources/blurp.css);
+ blink {
+ display: none;
+ }
+ </style>
+ <link rel="stylesheet" href="chrome://resources/bar.css">
+ </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, result.inlined_data)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « grit/format/html_inline.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698