Commit 60fb0d5a authored by Aran Gilman's avatar Aran Gilman Committed by Commit Bot

Apply preprocess_only recursively when inlining content.

Change-Id: Id77f761b8638094c73b571bad1704a4d5dd96f3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931543Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Aran Gilman <gilmanmh@google.com>
Cr-Commit-Position: refs/heads/master@{#722722}
parent 9fe3cf4b
...@@ -383,6 +383,7 @@ def DoInline( ...@@ -383,6 +383,7 @@ def DoInline(
# by DoInline. # by DoInline.
inlined_data_inst=DoInline(filepath, grd_node, inlined_data_inst=DoInline(filepath, grd_node,
allow_external_script=allow_external_script, allow_external_script=allow_external_script,
preprocess_only=preprocess_only,
strip_whitespace=strip_whitespace, strip_whitespace=strip_whitespace,
filename_expansion_function=filename_expansion_function) filename_expansion_function=filename_expansion_function)
......
...@@ -879,5 +879,49 @@ class HtmlInlineUnittest(unittest.TestCase): ...@@ -879,5 +879,49 @@ class HtmlInlineUnittest(unittest.TestCase):
tmp_dir.CleanUp() tmp_dir.CleanUp()
def testPreprocessOnlyAppliesRecursively(self):
'''Tests that preprocess_only=true propagates to included files. '''
files = {
'index.html': '''
<html>
<include src="outer_include.html">
</html>
''',
'outer_include.html': '''
<include src="inner_include.html">
<link rel="stylesheet" href="not_inlined.css">
''',
'inner_include.html': ''' <p>This should be inlined in index.html</p> ''',
'not_inlined.css': ''' /* This should not be inlined. */ '''
}
expected_inlined = '''
<html>
<p>This should be inlined in index.html</p>
<link rel="stylesheet" href="not_inlined.css">
</html>
'''
source_resources = set()
tmp_dir = util.TempDir(files)
source_resources.add(tmp_dir.GetPath('index.html'))
source_resources.add(tmp_dir.GetPath('outer_include.html'))
source_resources.add(tmp_dir.GetPath('inner_include.html'))
result = html_inline.DoInline(tmp_dir.GetPath('index.html'), None,
preprocess_only=True)
resources = result.inlined_files
resources.add(tmp_dir.GetPath('index.html'))
self.failUnlessEqual(resources, source_resources)
# Ignore whitespace
expected_inlined = re.sub(r'\s+', ' ', expected_inlined)
actually_inlined = re.sub(r'\s+', ' ',
util.FixLineEnd(result.inlined_data, '\n'))
self.failUnlessEqual(expected_inlined, actually_inlined)
tmp_dir.CleanUp()
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment