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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 EXPECT_EQ(expected_number_of_frames, actual_number_of_frames); | 966 EXPECT_EQ(expected_number_of_frames, actual_number_of_frames); |
967 | 967 |
968 for (const auto& expected_substring : expected_substrings) { | 968 for (const auto& expected_substring : expected_substrings) { |
969 int actual_number_of_matches = ui_test_utils::FindInPage( | 969 int actual_number_of_matches = ui_test_utils::FindInPage( |
970 GetCurrentTab(browser()), base::UTF8ToUTF16(expected_substring), | 970 GetCurrentTab(browser()), base::UTF8ToUTF16(expected_substring), |
971 true, // |forward| | 971 true, // |forward| |
972 true, // |case_sensitive| | 972 true, // |case_sensitive| |
973 nullptr, nullptr); | 973 nullptr, nullptr); |
974 | 974 |
975 EXPECT_EQ(1, actual_number_of_matches) | 975 EXPECT_EQ(1, actual_number_of_matches) |
976 << "Verifying if \"" << expected_substring << "\" appears " | 976 << "Verifying that \"" << expected_substring << "\" appears " |
977 << "exactly once in the web-contents text"; | 977 << "exactly once in the text of web contents"; |
978 } | 978 } |
979 | 979 |
980 int actual_number_of_errors = ui_test_utils::FindInPage( | 980 std::vector<std::string> forbidden_substrings{ |
981 GetCurrentTab(browser()), base::UTF8ToUTF16("err"), | 981 "head" // Html markup should not render. |
982 true, // |forward| | 982 "err", // Used in error messages + included as text content |
983 false, // |case_sensitive| | 983 // of <object> elements (in case the object itself doesn't |
984 nullptr, nullptr); | 984 // render). |
985 EXPECT_EQ(0, actual_number_of_errors); | 985 }; |
| 986 |
| 987 for (const auto& forbidden_substring : forbidden_substrings) { |
| 988 int actual_number_of_matches = ui_test_utils::FindInPage( |
| 989 GetCurrentTab(browser()), base::UTF8ToUTF16(forbidden_substring), |
| 990 true, // |forward| |
| 991 true, // |case_sensitive| |
| 992 nullptr, nullptr); |
| 993 |
| 994 EXPECT_EQ(0, actual_number_of_matches) |
| 995 << "Verifying that \"" << forbidden_substring << "\" doesn't " |
| 996 << "appear in the text of web contents"; |
| 997 } |
986 } | 998 } |
987 | 999 |
988 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { | 1000 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { |
989 (*i)++; | 1001 (*i)++; |
990 } | 1002 } |
991 }; | 1003 }; |
992 | 1004 |
993 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and | 1005 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and |
994 // MHTML (crbug.com/538766) as well as for redirected iframes saved | 1006 // MHTML (crbug.com/538766) as well as for redirected iframes saved |
995 // as MHTML (crbug.com/539936). | 1007 // as MHTML (crbug.com/539936). |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", | 1081 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", |
1070 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1082 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
1071 }; | 1083 }; |
1072 | 1084 |
1073 GURL url( | 1085 GURL url( |
1074 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); | 1086 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); |
1075 | 1087 |
1076 TestMultiFramePage(save_page_type, url, 3, expected_substrings); | 1088 TestMultiFramePage(save_page_type, url, 3, expected_substrings); |
1077 } | 1089 } |
1078 | 1090 |
| 1091 // Test for saving frames with various encodings (crbug.com/541699). |
| 1092 // - iso-8859-2: single-byte encoding, encoding declared via <meta> element |
| 1093 // - utf32.htm - multi-byte encoding, detection via mocked http headers |
| 1094 // - euc-kr.htm - encoding via html entities |
| 1095 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, Encoding) { |
| 1096 content::SavePageType save_page_type = GetParam(); |
| 1097 |
| 1098 std::vector<std::string> expected_substrings{ |
| 1099 "frames-encodings.htm: f53295dd-a95b-4b32-85f5-b6e15377fb20", |
| 1100 "euc-kr.htm: 樂樂", |
| 1101 "iso-8859-2.htm: Zażółć gęślą jaźń", |
| 1102 "utf32.htm: Zażółć gęślą jaźń", |
| 1103 }; |
| 1104 |
| 1105 GURL url(embedded_test_server()->GetURL("a.com", |
| 1106 "/save_page/frames-encodings.htm")); |
| 1107 |
| 1108 // TODO(lukasza): crbug.com/541699: MHTML needs to handle multi-byte encodings |
| 1109 // by either: |
| 1110 // 1. Continuing to preserve the original encoding, but starting to round-trip |
| 1111 // the encoding declaration (in Content-Type MIME/MHTML header?) |
| 1112 // 2. Saving html docs in UTF8. |
| 1113 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) |
| 1114 return; |
| 1115 |
| 1116 TestMultiFramePage(save_page_type, url, 4, expected_substrings); |
| 1117 } |
| 1118 |
1079 INSTANTIATE_TEST_CASE_P( | 1119 INSTANTIATE_TEST_CASE_P( |
1080 , | 1120 , |
1081 SavePageMultiFrameBrowserTest, | 1121 SavePageMultiFrameBrowserTest, |
1082 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 1122 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
1083 content::SAVE_PAGE_TYPE_AS_MHTML)); | 1123 content::SAVE_PAGE_TYPE_AS_MHTML)); |
1084 | 1124 |
1085 } // namespace | 1125 } // namespace |
OLD | NEW |