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

Unified Diff: src/caterpillar_test.py

Issue 1644543005: inject_misc_tags no longer fails if document has no head. Resolves #16. (Closed) Base URL: git@github.com:chromium/caterpillar.git@master
Patch Set: Response to CR Created 4 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 | « src/caterpillar.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/caterpillar_test.py
diff --git a/src/caterpillar_test.py b/src/caterpillar_test.py
index 7ae50ff8e5beea0534d317deabb129782c30abbd..f5b316fe7a18ffc987ad4111448af99d496674fb 100755
--- a/src/caterpillar_test.py
+++ b/src/caterpillar_test.py
@@ -447,6 +447,58 @@ class TestInjectMiscTags(unittest.TestCase):
self.assertIsNotNone(meta)
self.assertEqual(meta['content'], chrome_app_manifest['name'])
+ def test_no_head(self):
+ """Tests that the manifest link tag is added even with no head."""
+ chrome_app_manifest = {}
+ root_path = 'path'
+ html = """\
+<!DOCTYPE html>
+<html>
+ <body>
+ <h1>
+ Héllo, World! ÚÑÍ¢ÓÐÉ
+ </h1>
+ </body>
+</html>"""
+ soup = bs4.BeautifulSoup(html, 'html.parser')
+ caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '')
+ self.assertEqual(unicode(soup), """\
+<!DOCTYPE html>
+
+<html><head><meta charset="utf-8"/><link href="path/manifest.webmanifest"\
+ rel="manifest"/></head>
+<body>
+<h1>
+ Héllo, World! ÚÑÍ¢ÓÐÉ
+ </h1>
+</body>
+</html>""")
+
+
+ def test_no_head_or_html(self):
+ """Tests that the manifest link tag is added with no head or html tags."""
+ chrome_app_manifest = {}
+ root_path = 'path'
+ html = """
+<!DOCTYPE html>
+<body>
+<h1>
+ Héllo, World! ÚÑÍ¢ÓÐÉ
+</h1>
+</body>"""
+ soup = bs4.BeautifulSoup(html, 'html.parser')
+ caterpillar.inject_misc_tags(soup, chrome_app_manifest, root_path, '')
+ self.assertEqual(unicode(soup), """\
+<head><meta charset="utf-8"/><link href="path/manifest.webmanifest"\
+ rel="manifest"/></head>
+<!DOCTYPE html>
+
+<body>
+<h1>
+ Héllo, World! ÚÑÍ¢ÓÐÉ
+</h1>
+</body>""")
+
class TestInsertTodosIntoFile(TestCaseWithTempDir):
"""Tests insert_todos_into_file."""
« no previous file with comments | « src/caterpillar.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698