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

Unified Diff: chrome_frame/test/html_util_unittests.cc

Issue 5708007: Have Chrome Frame "support" IE conditional comment tags (of the downlevel-hid... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | « chrome_frame/html_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_frame/test/html_util_unittests.cc
===================================================================
--- chrome_frame/test/html_util_unittests.cc (revision 68996)
+++ chrome_frame/test/html_util_unittests.cc (working copy)
@@ -213,12 +213,112 @@
HTMLScanner scanner(test_data.c_str());
- // Grab the meta tag from the document and ensure that we get exactly one.
+ // Ensure that the the meta tag is NOT detected.
HTMLScanner::StringRangeList tag_list;
scanner.GetTagsByName(L"meta", &tag_list, L"body");
ASSERT_TRUE(tag_list.empty());
}
+TEST_F(HtmlUtilUnittest, IEConditionalCommentTest) {
+ std::wstring test_data(
+ L"<!--[if lte IE 8]><META http-equiv=X-UA-Compatible content='chrome=1'/>"
+ L"<![endif]-->");
+
+ HTMLScanner scanner(test_data.c_str());
+
+ // Ensure that the the meta tag IS detected.
+ HTMLScanner::StringRangeList tag_list;
+ scanner.GetTagsByName(L"meta", &tag_list, L"body");
+ ASSERT_EQ(1, tag_list.size());
+}
+
+TEST_F(HtmlUtilUnittest, IEConditionalCommentWithNestedCommentTest) {
+ std::wstring test_data(
+ L"<!--[if IE]><!--<META http-equiv=X-UA-Compatible content='chrome=1'/>"
+ L"--><![endif]-->");
+
+ HTMLScanner scanner(test_data.c_str());
+
+ // Ensure that the the meta tag IS NOT detected.
+ HTMLScanner::StringRangeList tag_list;
+ scanner.GetTagsByName(L"meta", &tag_list, L"body");
+ ASSERT_TRUE(tag_list.empty());
+}
+
+TEST_F(HtmlUtilUnittest, IEConditionalCommentWithMultipleNestedTagsTest) {
+ std::wstring test_data(
+ L"<!--[if lte IE 8]> <META http-equiv=X-UA-Compatible "
+ L"content='chrome=1'/><foo bar></foo><foo baz/><![endif]-->"
+ L"<boo hoo><boo hah>");
+
+ HTMLScanner scanner(test_data.c_str());
+
+ // Ensure that the the meta tag IS detected.
+ HTMLScanner::StringRangeList meta_tag_list;
+ scanner.GetTagsByName(L"meta", &meta_tag_list, L"body");
+ ASSERT_EQ(1, meta_tag_list.size());
+
+ // Ensure that the foo tags are also detected.
+ HTMLScanner::StringRangeList foo_tag_list;
+ scanner.GetTagsByName(L"foo", &foo_tag_list, L"body");
+ ASSERT_EQ(2, foo_tag_list.size());
+
+ // Ensure that the boo tags are also detected.
+ HTMLScanner::StringRangeList boo_tag_list;
+ scanner.GetTagsByName(L"boo", &boo_tag_list, L"body");
+ ASSERT_EQ(2, boo_tag_list.size());
+}
+
+TEST_F(HtmlUtilUnittest, IEConditionalCommentWithAlternateEndingTest) {
+ std::wstring test_data(
+ L"<!--[if lte IE 8]> <META http-equiv=X-UA-Compatible "
+ L"content='chrome=1'/><foo bar></foo><foo baz/><![endif]>"
+ L"<boo hoo><!--><boo hah>");
+
+ HTMLScanner scanner(test_data.c_str());
+
+ // Ensure that the the meta tag IS detected.
+ HTMLScanner::StringRangeList meta_tag_list;
+ scanner.GetTagsByName(L"meta", &meta_tag_list, L"body");
+ ASSERT_EQ(1, meta_tag_list.size());
+
+ // Ensure that the foo tags are also detected.
+ HTMLScanner::StringRangeList foo_tag_list;
+ scanner.GetTagsByName(L"foo", &foo_tag_list, L"body");
+ ASSERT_EQ(2, foo_tag_list.size());
+
+ // Ensure that the boo tags are also detected.
+ HTMLScanner::StringRangeList boo_tag_list;
+ scanner.GetTagsByName(L"boo", &boo_tag_list, L"body");
+ ASSERT_EQ(2, boo_tag_list.size());
+}
+
+TEST_F(HtmlUtilUnittest, IEConditionalCommentNonTerminatedTest) {
+ // This test shouldn't detect any tags up until the end of the conditional
+ // comment tag.
+ std::wstring test_data(
+ L"<!--[if lte IE 8> <META http-equiv=X-UA-Compatible "
+ L"content='chrome=1'/><foo bar></foo><foo baz/><![endif]>"
+ L"<boo hoo><!--><boo hah>");
+
+ HTMLScanner scanner(test_data.c_str());
+
+ // Ensure that the the meta tag IS NOT detected.
+ HTMLScanner::StringRangeList meta_tag_list;
+ scanner.GetTagsByName(L"meta", &meta_tag_list, L"body");
+ ASSERT_TRUE(meta_tag_list.empty());
+
+ // Ensure that the foo tags are NOT detected.
+ HTMLScanner::StringRangeList foo_tag_list;
+ scanner.GetTagsByName(L"foo", &foo_tag_list, L"body");
+ ASSERT_TRUE(foo_tag_list.empty());
+
+ // Ensure that the boo tags are detected.
+ HTMLScanner::StringRangeList boo_tag_list;
+ scanner.GetTagsByName(L"boo", &boo_tag_list, L"body");
+ ASSERT_EQ(2, boo_tag_list.size());
+}
+
TEST_F(HtmlUtilUnittest, AddChromeFrameToUserAgentValue) {
struct TestCase {
std::string input_;
« no previous file with comments | « chrome_frame/html_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698