OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 EXPECT_EQ(expected_number_of_frames, actual_number_of_frames); | 969 EXPECT_EQ(expected_number_of_frames, actual_number_of_frames); |
970 | 970 |
971 for (const auto& expected_substring : expected_substrings) { | 971 for (const auto& expected_substring : expected_substrings) { |
972 int actual_number_of_matches = ui_test_utils::FindInPage( | 972 int actual_number_of_matches = ui_test_utils::FindInPage( |
973 GetCurrentTab(browser()), base::UTF8ToUTF16(expected_substring), | 973 GetCurrentTab(browser()), base::UTF8ToUTF16(expected_substring), |
974 true, // |forward| | 974 true, // |forward| |
975 true, // |case_sensitive| | 975 true, // |case_sensitive| |
976 nullptr, nullptr); | 976 nullptr, nullptr); |
977 | 977 |
978 EXPECT_EQ(1, actual_number_of_matches) | 978 EXPECT_EQ(1, actual_number_of_matches) |
979 << "Verifying if \"" << expected_substring << "\" appears " | 979 << "Verifying that \"" << expected_substring << "\" appears " |
980 << "exactly once in the web-contents text"; | 980 << "exactly once in the text of web contents"; |
981 } | 981 } |
982 | 982 |
983 int actual_number_of_errors = ui_test_utils::FindInPage( | 983 std::string forbidden_substrings[] = { |
984 GetCurrentTab(browser()), base::UTF8ToUTF16("err"), | 984 "head" // Html markup should not be visible. |
985 true, // |forward| | 985 "err", // "err" is a prefix of error messages + is included as text |
986 false, // |case_sensitive| | 986 // content of <object> elements in some test files (text content |
987 nullptr, nullptr); | 987 // would be rendered in case the object itself doesn't work). |
988 EXPECT_EQ(0, actual_number_of_errors); | 988 }; |
| 989 for (const auto& forbidden_substring : forbidden_substrings) { |
| 990 int actual_number_of_matches = ui_test_utils::FindInPage( |
| 991 GetCurrentTab(browser()), base::UTF8ToUTF16(forbidden_substring), |
| 992 true, // |forward| |
| 993 true, // |case_sensitive| |
| 994 nullptr, nullptr); |
| 995 |
| 996 EXPECT_EQ(0, actual_number_of_matches) |
| 997 << "Verifying that \"" << forbidden_substring << "\" doesn't " |
| 998 << "appear in the text of web contents"; |
| 999 } |
989 } | 1000 } |
990 | 1001 |
991 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { | 1002 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { |
992 (*i)++; | 1003 (*i)++; |
993 } | 1004 } |
994 }; | 1005 }; |
995 | 1006 |
996 // Test coverage for: | 1007 // Test coverage for: |
997 // - crbug.com/526786: OOPIFs support for CompleteHtml | 1008 // - crbug.com/526786: OOPIFs support for CompleteHtml |
998 // - crbug.com/538766: OOPIFs support for MHTML | 1009 // - crbug.com/538766: OOPIFs support for MHTML |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 expected_substrings = std::vector<std::string>( | 1134 expected_substrings = std::vector<std::string>( |
1124 std::begin(complete_html_arr), std::end(complete_html_arr)); | 1135 std::begin(complete_html_arr), std::end(complete_html_arr)); |
1125 } | 1136 } |
1126 | 1137 |
1127 GURL url(embedded_test_server()->GetURL( | 1138 GURL url(embedded_test_server()->GetURL( |
1128 "a.com", "/save_page/frames-runtime-changes.htm?do_runtime_changes=1")); | 1139 "a.com", "/save_page/frames-runtime-changes.htm?do_runtime_changes=1")); |
1129 | 1140 |
1130 TestMultiFramePage(save_page_type, url, 5, expected_substrings); | 1141 TestMultiFramePage(save_page_type, url, 5, expected_substrings); |
1131 } | 1142 } |
1132 | 1143 |
| 1144 // Test for saving frames with various encodings: |
| 1145 // - iso-8859-2: encoding declared via <meta> element |
| 1146 // - utf16-le-bom.htm, utf16-be-bom.htm: encoding detected via BOM |
| 1147 // - utf16-le-nobom.htm, utf16-le-nobom.htm, utf32.htm - encoding declared via |
| 1148 // mocked http headers |
| 1149 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, Encoding) { |
| 1150 content::SavePageType save_page_type = GetParam(); |
| 1151 |
| 1152 std::string arr[] = { |
| 1153 "frames-encodings.htm: f53295dd-a95b-4b32-85f5-b6e15377fb20", |
| 1154 "iso-8859-2.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " |
| 1155 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", |
| 1156 "utf16-le-nobom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " |
| 1157 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", |
| 1158 "utf16-le-bom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " |
| 1159 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", |
| 1160 "utf16-be-nobom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " |
| 1161 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", |
| 1162 "utf16-be-bom.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " |
| 1163 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", |
| 1164 "utf32.htm: Za\xc5\xbc\xc3\xb3\xc5\x82\xc4\x87 " |
| 1165 "g\xc4\x99\xc5\x9bl\xc4\x85 ja\xc5\xba\xc5\x84", |
| 1166 }; |
| 1167 std::vector<std::string> expected_substrings(std::begin(arr), std::end(arr)); |
| 1168 |
| 1169 GURL url(embedded_test_server()->GetURL("a.com", |
| 1170 "/save_page/frames-encodings.htm")); |
| 1171 |
| 1172 // TODO(lukasza): crbug.com/541699: MHTML needs to handle multi-byte encodings |
| 1173 // by either: |
| 1174 // 1. Continuing to preserve the original encoding, but starting to round-trip |
| 1175 // the encoding declaration (in Content-Type MIME/MHTML header?) |
| 1176 // 2. Saving html docs in UTF8. |
| 1177 // 3. Saving the BOM (not sure if this will help for all cases though). |
| 1178 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) |
| 1179 return; |
| 1180 |
| 1181 TestMultiFramePage(save_page_type, url, 7, expected_substrings); |
| 1182 } |
| 1183 |
1133 INSTANTIATE_TEST_CASE_P( | 1184 INSTANTIATE_TEST_CASE_P( |
1134 SaveType, | 1185 SaveType, |
1135 SavePageMultiFrameBrowserTest, | 1186 SavePageMultiFrameBrowserTest, |
1136 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 1187 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
1137 content::SAVE_PAGE_TYPE_AS_MHTML)); | 1188 content::SAVE_PAGE_TYPE_AS_MHTML)); |
1138 | 1189 |
1139 } // namespace | 1190 } // namespace |
OLD | NEW |