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{ |
jsbell
2015/12/08 01:19:07
http://chromium-cpp.appspot.com/ says that the "un
Łukasz Anforowicz
2015/12/09 00:50:59
Yes, sorry about that. I should have rebased onto
| |
981 GetCurrentTab(browser()), base::UTF8ToUTF16("err"), | 981 "head" // Html markup should not be visible. |
982 true, // |forward| | 982 "err", // "err" is a prefix of error messages + is included as text |
983 false, // |case_sensitive| | 983 // content of <object> elements in some test files (text content |
984 nullptr, nullptr); | 984 // would be rendered in case the object itself doesn't work). |
985 EXPECT_EQ(0, actual_number_of_errors); | 985 }; |
986 for (const auto& forbidden_substring : forbidden_substrings) { | |
987 int actual_number_of_matches = ui_test_utils::FindInPage( | |
988 GetCurrentTab(browser()), base::UTF8ToUTF16(forbidden_substring), | |
989 true, // |forward| | |
990 true, // |case_sensitive| | |
991 nullptr, nullptr); | |
992 | |
993 EXPECT_EQ(0, actual_number_of_matches) | |
994 << "Verifying that \"" << forbidden_substring << "\" doesn't " | |
995 << "appear in the text of web contents"; | |
996 } | |
986 } | 997 } |
987 | 998 |
988 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { | 999 static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) { |
989 (*i)++; | 1000 (*i)++; |
990 } | 1001 } |
991 }; | 1002 }; |
992 | 1003 |
993 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and | 1004 // Test coverage for OOPIFs for CompleteHtml (crbug.com/526786) and |
994 // MHTML (crbug.com/538766) as well as for redirected iframes saved | 1005 // MHTML (crbug.com/538766) as well as for redirected iframes saved |
995 // as MHTML (crbug.com/539936). | 1006 // 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", | 1080 "frames-nested2.htm: 6d23dc47-f283-4977-96ec-66bcf72301a4", |
1070 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", | 1081 "b.htm: 3a35f7fa-96a9-4487-9f18-4470263907fa", |
1071 }; | 1082 }; |
1072 | 1083 |
1073 GURL url( | 1084 GURL url( |
1074 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); | 1085 embedded_test_server()->GetURL("a.com", "/save_page/frames-nested.htm")); |
1075 | 1086 |
1076 TestMultiFramePage(save_page_type, url, 3, expected_substrings); | 1087 TestMultiFramePage(save_page_type, url, 3, expected_substrings); |
1077 } | 1088 } |
1078 | 1089 |
1090 // Test for saving frames with various encodings (crbug.com/541699). | |
jsbell
2015/12/08 01:19:07
I don't think including the bug# here is necessary
Łukasz Anforowicz
2015/12/09 00:50:59
Done.
| |
1091 // - iso-8859-2: encoding declared via <meta> element | |
1092 // - utf16-le-bom.htm, utf16-be-bom.htm: encoding detected via BOM | |
1093 // - utf16-le-nobom.htm, utf16-le-nobom.htm, utf32.htm - encoding declared via | |
1094 // mocked http headers | |
1095 IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, Encoding) { | |
1096 content::SavePageType save_page_type = GetParam(); | |
1097 | |
1098 std::vector<std::string> expected_substrings{ | |
jsbell
2015/12/08 01:19:07
(see above)
Łukasz Anforowicz
2015/12/09 00:50:59
Done.
| |
1099 "frames-encodings.htm: f53295dd-a95b-4b32-85f5-b6e15377fb20", | |
1100 "iso-8859-2.htm: Zażółć gęślą jaźń", | |
jsbell
2015/12/08 01:19:07
Use \x## escapes so that the source is ASCII when
Łukasz Anforowicz
2015/12/09 00:50:59
Is \u escape ok? It fits into 80 columns limit be
jsbell
2015/12/09 01:02:47
https://google.github.io/styleguide/cppguide.html#
Łukasz Anforowicz
2015/12/09 01:27:36
Done.
| |
1101 "utf16-le-nobom.htm: Zażółć gęślą jaźń", | |
1102 "utf16-le-bom.htm: Zażółć gęślą jaźń", | |
1103 "utf16-be-nobom.htm: Zażółć gęślą jaźń", | |
1104 "utf16-be-bom.htm: Zażółć gęślą jaźń", | |
1105 "utf32.htm: Zażółć gęślą jaźń", | |
1106 }; | |
1107 | |
1108 GURL url(embedded_test_server()->GetURL("a.com", | |
1109 "/save_page/frames-encodings.htm")); | |
1110 | |
1111 // TODO(lukasza): crbug.com/541699: MHTML needs to handle multi-byte encodings | |
1112 // by either: | |
1113 // 1. Continuing to preserve the original encoding, but starting to round-trip | |
1114 // the encoding declaration (in Content-Type MIME/MHTML header?) | |
1115 // 2. Saving html docs in UTF8. | |
1116 // 3. Saving the BOM (this won't help for all cases though). | |
1117 if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML) | |
1118 return; | |
1119 | |
1120 TestMultiFramePage(save_page_type, url, 7, expected_substrings); | |
1121 } | |
1122 | |
1079 INSTANTIATE_TEST_CASE_P( | 1123 INSTANTIATE_TEST_CASE_P( |
1080 , | 1124 , |
1081 SavePageMultiFrameBrowserTest, | 1125 SavePageMultiFrameBrowserTest, |
1082 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, | 1126 ::testing::Values(content::SAVE_PAGE_TYPE_AS_COMPLETE_HTML, |
1083 content::SAVE_PAGE_TYPE_AS_MHTML)); | 1127 content::SAVE_PAGE_TYPE_AS_MHTML)); |
1084 | 1128 |
1085 } // namespace | 1129 } // namespace |
OLD | NEW |