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

Unified Diff: chrome/browser/download/save_page_browsertest.cc

Issue 1407663004: Tweaking WebPageSerializerImpl to emit a BOM for UTF16/32. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Saving UTF16 with BOM. Leaving UTF32 in a broken state. Created 5 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
Index: chrome/browser/download/save_page_browsertest.cc
diff --git a/chrome/browser/download/save_page_browsertest.cc b/chrome/browser/download/save_page_browsertest.cc
index 6bd94ca14d58794d9d23d67e680f4f2d682f1565..23b3dd5f2cce4bbf7457d99f5065c274d29ba695 100644
--- a/chrome/browser/download/save_page_browsertest.cc
+++ b/chrome/browser/download/save_page_browsertest.cc
@@ -973,16 +973,27 @@ class SavePageMultiFrameBrowserTest
nullptr, nullptr);
EXPECT_EQ(1, actual_number_of_matches)
- << "Verifying if \"" << expected_substring << "\" appears "
- << "exactly once in the web-contents text";
+ << "Verifying that \"" << expected_substring << "\" appears "
+ << "exactly once in the text of web contents";
}
- int actual_number_of_errors = ui_test_utils::FindInPage(
- GetCurrentTab(browser()), base::UTF8ToUTF16("err"),
- true, // |forward|
- false, // |case_sensitive|
- nullptr, nullptr);
- EXPECT_EQ(0, actual_number_of_errors);
+ std::vector<std::string> forbidden_substrings{
+ "head" // Html markup should not be visible.
+ "err", // "err" is a prefix of error messages + is included as text
+ // content of <object> elements in some test files (text content
+ // would be rendered in case the object itself doesn't work).
+ };
+ for (const auto& forbidden_substring : forbidden_substrings) {
+ int actual_number_of_matches = ui_test_utils::FindInPage(
+ GetCurrentTab(browser()), base::UTF8ToUTF16(forbidden_substring),
+ true, // |forward|
+ true, // |case_sensitive|
+ nullptr, nullptr);
+
+ EXPECT_EQ(0, actual_number_of_matches)
+ << "Verifying that \"" << forbidden_substring << "\" doesn't "
+ << "appear in the text of web contents";
+ }
}
static void IncrementInteger(int* i, content::RenderFrameHost* /* unused */) {
@@ -1076,6 +1087,40 @@ IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, NestedFrames) {
TestMultiFramePage(save_page_type, url, 3, expected_substrings);
}
+// Test for saving frames with various encodings (crbug.com/541699).
+// - iso-8859-2: encoding declared via <meta> element
+// - utf16-le-bom.htm, utf16-be-bom.htm: encoding detected via BOM
+// - utf16-le-nobom.htm, utf16-le-nobom.htm, utf32.htm - encoding declared via
+// mocked http headers
+IN_PROC_BROWSER_TEST_P(SavePageMultiFrameBrowserTest, Encoding) {
+ content::SavePageType save_page_type = GetParam();
+
+ std::vector<std::string> expected_substrings{
+ "frames-encodings.htm: f53295dd-a95b-4b32-85f5-b6e15377fb20",
+ "iso-8859-2.htm: Zażółć gęślą jaźń",
+ "utf16-le-nobom.htm: Zażółć gęślą jaźń",
+ "utf16-le-bom.htm: Zażółć gęślą jaźń",
+ "utf16-be-nobom.htm: Zażółć gęślą jaźń",
+ "utf16-be-bom.htm: Zażółć gęślą jaźń",
+ // TODO(lukasza): Fix UTF32 (otoh it is low-priority compared with UTF16).
+ // "utf32.htm: Zażółć gęślą jaźń",
+ };
+
+ GURL url(embedded_test_server()->GetURL("a.com",
+ "/save_page/frames-encodings.htm"));
+
+ // TODO(lukasza): crbug.com/541699: MHTML needs to handle multi-byte encodings
+ // by either:
+ // 1. Continuing to preserve the original encoding, but starting to round-trip
+ // the encoding declaration (in Content-Type MIME/MHTML header?)
+ // 2. Saving html docs in UTF8.
+ // 3. Saving the BOM (this won't help for all cases though).
+ if (save_page_type == content::SAVE_PAGE_TYPE_AS_MHTML)
+ return;
+
+ TestMultiFramePage(save_page_type, url, 7, expected_substrings);
+}
+
INSTANTIATE_TEST_CASE_P(
,
SavePageMultiFrameBrowserTest,

Powered by Google App Engine
This is Rietveld 408576698